Laravel Create Article
migrations
- use increments to auto_increment id’s value
- string type can not be null when applying to id
- use timestamp to create two fields
- created_at
- updated_at
- when using factory, the table will be automately filled update time and create date to the relative fields
Create Article
1 | // create controller with resource methods |
seeder
- there are two ways to insert data to table via command line
1 | > php artisan db:seed |
- both ways need adding customed seeder to Databaseseeder.php
- db:seed however only execute seeds run() function
- if you don’t want to use factory to get fake data, you can just use db:seed command to insert your customed data.
- remember to add the seeder you create to Databaseseeder.php
set index to field(migrations)
- belongsTo
1 | // \database\migrations\2018_10_05_094912_message_board_table.php |
1 | // app\Messageboard.php |