Database

The database is automatically generated by Laravel. Here are some usefull commands to keep in mind while interacting with the automatically generated database. All following command should be executed at the root of the project directory.

Note

While trying to make a new table for data, Please do not create any extra tables yourself and use the built in database->migration folder.

Note

Make sure the database connection settings in your .env file are set accordingly. For a XAMPP install, go to Installation and make sure to have followed all the steps.

Usefull command list

  • php artisan migrate -> Creates the database according to the database -> migrations files

  • php artisan migrate:install -> Only installs the migrate-manager and doesn’t run any files.

  • php artisan migrate:status -> Shows the status of the database migrations

  • php artisan migrate:reset -> Resets the entire database back to 0.

  • ``php artisan db:seed`v -> Fills the database with dummy data (found in database -> seeders)

  • php artisan make:migration DESCRIPTION -> Creates a new migrate job, in the created file you can make your changes to the database

  • php artisan make:model NAME -> Creates a new model, which can be hooked to the database

To view all the ways you can interact with the database, go to the api page. Here you can find all the available endpoints that can interact with the database to get and store data.

Creating Tables

  • $table->foreignId(‘user_id’)->constrained(); -> Creates a column called user_id that has a foreign key constrain with the column id in the user table