コード例 #1
0
ファイル: SubTableSeeder.php プロジェクト: ntzm/laravit
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\Sub::class, 4)->create()->each(function ($sub) {
         $sub->owner()->associate(App\User::random()->first());
         $sub->save();
     });
 }
コード例 #2
0
ファイル: PostTableSeeder.php プロジェクト: ntzm/laravit
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\Post::class, 100)->create()->each(function ($post) {
         $post->user()->associate(App\User::random()->first());
         $post->sub()->associate(App\Sub::random()->first());
         $post->save();
     });
 }
コード例 #3
0
ファイル: CommentTableSeeder.php プロジェクト: ntzm/laravit
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\Comment::class, 500)->create()->each(function ($comment) {
         $comment->user()->associate(App\User::random()->first());
         $comment->post()->associate(App\Post::random()->first());
         // TODO: Seed parent/child comment relationship
         $comment->save();
     });
 }