/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $content = "この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。この文章はダミーです。あいうえおかきくけこ。"; $commentdammy = "コメントダミー。コメントダミー。コメントダミー。"; for ($i = 1; $i <= 10; $i++) { $post = new App\Post(); $post->title = "{$i} 番目の投稿"; $post->content = $content; $post->cat_id = 1; $post->save(); $maxComments = mt_rand(3, 15); for ($j = 0; $j <= $maxComments; $j++) { $comment = new App\Comment(); $comment->commenter = '名無しさん'; $comment->comment = $commentdammy; $post->comments()->save($comment); $post->increment('comment_count'); } } // Category $cat1 = new App\Category(); $cat1->name = "ニュース"; $cat1->save(); $cat2 = new App\Category(); $cat2->name = "食品"; $cat2->save(); $cat3 = new App\Category(); $cat3->name = "電化製品"; $cat3->save(); $cat4 = new App\Category(); $cat4->name = "テレビ"; $cat4->save(); $cat5 = new App\Category(); $cat5->name = "文化"; $cat5->save(); $cat6 = new App\Category(); $cat6->name = "映画"; $cat6->save(); $cat7 = new App\Category(); $cat7->name = "スポーツ"; $cat7->save(); $cat8 = new App\Category(); $cat8->name = "ゲーム"; $cat8->save(); $cat9 = new App\Category(); $cat9->name = "社会"; $cat9->save(); $cat10 = new App\Category(); $cat10->name = "教育"; $cat10->save(); }