laravel-learn-bbs/database/seeds/TopicsTableSeeder.php
2018-01-01 12:00:45 +08:00

21 lines
383 B
PHP

<?php
use App\Models\Topic;
use Illuminate\Database\Seeder;
class TopicsTableSeeder extends Seeder
{
public function run()
{
$topics = factory(Topic::class)->times(50)->make()->each(function ($topic, $index) {
if ($index == 0) {
// $topic->field = 'value';
}
});
Topic::insert($topics->toArray());
}
}