php artisan make:migration create_links_table
{timestamp}_create_links_table.php
up()
down()
Schema::create('links', function (Blueprint $table) {
$table->id();
$table->string('title'),
$table->timestamps();
});
php artisan migrate
php artisan make:model Link
php artisan make:factory LinkFactory
public function definition()
{
return [
'name' => $this->faker->name()
];
}
php artisan make:seeder LinksSeeder
run()
方法会在 db:seed
执行 public function run()
{
Link::factory()->count(10)->create();
}
databases/seeders/DatabaseSeeder.php
public function run()
{
$this->call(ColumnsSeeder::class);
}
php artisan db:seed