Пример #1
0
 public function getIndex(Request $request)
 {
     // Get all the books "owned" by the current logged in users
     // Sort in descending order by id
     $birds = \Birdwatcher\Bird::where('bird_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     return view('birds.index')->with('birds', $birds);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = \Birdwatcher\User::all();
     foreach ($users as $name => $birds) {
         $user = \Birdwatcher\User::where('name', 'like', $name)->first();
         foreach ($birds as $birdName) {
             $bird = \Birdwatcher\Bird::where('name', 'LIKE', $birdName)->first();
             $user->birds()->save($bird);
         }
     }
 }