Route::get('/sponsorCat', function () { // $book = \App\Book::where('title','=','The Great Gatsby')->first(); // // echo $book->title.' is tagged with: '; // foreach($book->tags as $tag) { // echo $tag->name.' '; // } $animal = \CareCats\Animal::where('name', '=', 'Matt')->first(); echo '<br /><br />' . $animal->name . ' is sponsored by: '; foreach ($animal->sponsors as $sponsor) { echo $sponsor->first_name . ', '; } }); Route::get('/sponsorCat2', function () { #eagerly loaded $animals = \CareCats\Animal::with('sponsors')->get(); foreach ($animals as $animal) { echo '<br>' . $animal->name . ' is sponsored by: '; foreach ($animal->sponsors as $sponsor) { echo $sponsor->first_name . ', '; } } }); # Show login form Route::get('/login', 'Auth\\AuthController@getLogin'); # Process login form Route::post('/login', 'Auth\\AuthController@postLogin'); # Process logout Route::get('/logout', 'Auth\\AuthController@getLogout'); # Show registration form Route::get('/register', 'Auth\\AuthController@getRegister');