laravel-learn-bbs/database/seeds/TopicsTableSeeder.php

21 lines
383 B
PHP
Raw Normal View History

2018-01-01 04:00:45 +00:00
<?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());
}
}