Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $kid_id = \P4\Kid::where('name', '=', 'Jasper')->pluck('id');
     DB::table('photos')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'Easy Jasper in basket', 'image_url' => 'http://d3drsuq3xbnvq3.cloudfront.net/jp/pictures/201512/537083047/736D1327C4744FADBA97B2438DBCC167.jpg', 'kid_id' => $kid_id]);
     DB::table('photos')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'Happy Jasper on train', 'image_url' => 'http://d3drsuq3xbnvq3.cloudfront.net/jp/pictures/201512/537083047/778FD37C1A554E73AF0824971024E6D6.jpg', 'kid_id' => $kid_id]);
     DB::table('photos')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'Dizzy Jasper playing on toy piano', 'image_url' => 'http://d3drsuq3xbnvq3.cloudfront.net/jp/pictures/201512/537083429/5be3818bf638483a82d49c8cb2d17eb0.jpg', 'kid_id' => $kid_id]);
     $kid_id = \P4\Kid::where('name', '=', 'John')->pluck('id');
     DB::table('photos')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'Busy Panda John', 'image_url' => 'http://www.bajiroo.com/wp-content/uploads/2013/01/Funny-Baby-kids-child-images-fun-bajiroo-photos-14.jpg', 'kid_id' => $kid_id]);
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $kids = ['John' => ['Jill', 'Jamal', 'Jean'], 'Jasper' => ['Jean'], 'Olivia' => ['Jill', 'Jean'], 'Emily' => ['Jamal', 'Jean']];
     # Now loop through the above array, creating a new pivot for each kid corresponding to user
     foreach ($kids as $name => $users) {
         # First get the kid name matched
         $kid = \P4\Kid::where('name', 'like', $name)->first();
         # Loop through all users for each kid
         foreach ($users as $userName) {
             $user = \P4\User::where('name', 'like', $userName)->first();
             # Save the kid's users info
             $kid->users()->save($user);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # First, create an array of all the users we want to associate kids with
     # The *key* will be the user email, and the *value* will be an array of tags.
     $users = ['*****@*****.**' => ['Julius', 'Pah'], '*****@*****.**' => ['Brett', 'Mary', 'Jus']];
     # Now loop through the above array, creating a new pivot for each user to kid
     foreach ($users as $email => $kids) {
         # First get the user
         $user = \p4\User::where('email', 'like', $email)->first();
         echo nl2br("user " . $user . "\n");
         # Now loop through each kid for this book, adding the pivot
         foreach ($kids as $firstname) {
             echo nl2br("firstname " . $firstname . "\n");
             $kid = \p4\Kid::where('firstname', 'LIKE', $firstname)->first();
             # Connect this user to this kid
             $user->kids()->attach($kid);
         }
     }
 }