Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $types = Type::all();
     $types->toarray();
     $tips = Tip::all();
     $tips->toarray();
     $breeds = Breed::all();
     $breeds->toarray();
     // $tips = DB::table('pet_tips')
     // 		->where('breed_id', '=', $breed_id)
     //    		->get();
     return View::make('tips.tips', compact('types', 'breeds', 'tips'));
 }
Example #2
0
<?php

Route::model('cat', 'Cat');
View::composer('cats.edit', function ($view) {
    $breeds = Breed::all();
    $breed_options = array_combine($breeds->lists('id'), $breeds->lists('name'));
    $view->with('breed_options', $breed_options);
});
Route::get('/', function () {
    return Redirect::to("cats");
});
Route::get('about', function () {
    return View::make('about')->with('number_of_cats', 9000);
});
Route::get('cats', function () {
    $cats = Cat::all();
    return View::make('cats/index')->with('cats', $cats);
});
Route::get('cats/breeds/{name}', function ($name) {
    $breed = Breed::whereName($name)->with('cats')->first();
    return View::make('cats/index')->with('breed', $breed)->with('cats', $breed->cats);
});
Route::get('cats/create', function () {
    $cat = new Cat();
    return View::make('cats.edit')->with('cat', $cat)->with('method', 'post');
});
Route::post('cats', function () {
    $cat = Cat::create(Input::all());
    return Redirect::to('cats/' . $cat->id)->with('message', 'Profil zostaƂ utworzony!');
});
Route::get('cats/{id}', function ($id) {