public function editService(Service $service)
 {
     $allPets = Pet::all();
     $pets = array();
     foreach ($allPets as $pet) {
         $pets[$pet->id] = $pet->name;
     }
     return View::make('edit_service', compact('service', 'pets'));
 }
 public function listPets()
 {
     $pets = Pet::all();
     return View::make('pets', compact('pets'));
 }
Esempio n. 3
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::model('pet', 'Pet');
Route::get('/', function () {
    return Redirect::to("pets");
});
Route::get('pets', function () {
    $pets = Pet::all();
    return View::make('pets.index')->with('pets', $pets);
});
Route::get('pets/ordered', function () {
    $pets = Pet::orderBy('age', 'ASC')->get();
    return View::make('pets/index')->with('pets', $pets);
});
Route::get('pets/cats', function () {
    $pets = Pet::where('type', 'cat')->get();
    return View::make('pets/index')->with('pets', $pets);
});