<?php Route::get('/', function () { return redirect('cats'); }); Route::get('cats', function () { $cats = Furbook\Cat::all(); return view('cats.index')->with('cats', $cats); }); Route::get('cats/breeds/{name}', function () { $breed = Furbook\Breed::with('cats')->whereName($name)->get(); return view('cats.index')->with('breeds', $breeds)->with('cats', $cats); }); Route::get('cats/create', function () { return view('cats.create'); }); Route::get('cats/{cat}', function (Furbook\Cat $cat) { return view('cats.show')->with('cat', $cat); })->where('id', '[0-9]+'); Route::post('cats', function () { $cat = Furbook\Cat::create(Input::all()); return redirect('cats/' . $cat->id)->withSuccess('Cat has been created.'); }); Route::get('cats/{cat}/edit', function (Furbook\Cat $cat) { return view('cats.edit')->with('cat', $cat); }); Route::put('cats/{cat}', function (Furbook\Cat $cat) { $cat->update(Input::all()); return redirect('cats/' . $cat->id)->withSuccess('Cat has been updated.'); }); Route::delete('cats/{cat}', function (Furbook\Cat $cat) {
Route::get('cats', function () { $cats = Furbook\Cat::all(); // echo '<pre>'; // var_dump($cats); // echo print_r($cats, true); // echo '</pre>'; // return 'All cats bastard'; return view('cats.index')->with('cats', $cats); }); Route::get('cats/breeds/{name}', function ($name) { $breed = Furbook\Breed::with('cats')->whereName($name)->first(); return view('cats.index')->with('breed', $breed)->with('cats', $breed->cats); }); Route::get('cats/{cat}', function (Furbook\Cat $cat) { return view('cats.show')->with('cats', $cat); }); Route::get('cats/{cat}/edit', function (Furbook\Cat $cat) { //echo '<pre>', print_r($cat, true), '</pre>'; $breeds = Furbook\Breed::all(); $arrBreeds = array(); foreach ($breeds as $breed) { $arrBreeds[$breed->id] = $breed->name; } return view('cats.edit')->with('cat', $cat)->with('breeds', $arrBreeds); }); Route::post('cats/{cat}', function (Furbook\Cat $cat) { $cat->update(Input::all()); return redirect('cats/' . $cat->id)->withSuccess('Cat has been updated.'); }); // user Route::get('user/{id}', ['uses' => 'UserController@show']);