예제 #1
0
 function beforeroute()
 {
     //list of categories
     $cats = new Cat($this->db);
     $this->f3->set('cs', $cats->all());
     //item count (menu)
     $items = new Item($this->db);
     $nb = $items->itemcount();
     $this->f3->set('cgall', $nb);
     //category menu
     $cgs = new CatGroup($this->db);
     $this->f3->set('cgs', $cgs->all());
 }
 public function index()
 {
     $category = new Cat($this->db);
     $this->f3->set('categoires', $category->all());
     $this->f3->set('header', 'Category List');
     //template
     $this->f3->set('view', 'cats/list.htm');
     //menu
     $this->f3->set('topmenu', 'c');
     //breadcrumbs
     $this->f3->set('breadcrumb', array(array("url" => NULL, "name" => "Categories")));
     //display messages (if not empty) and clear values
     if ($this->f3->get('COOKIE.message')) {
         $this->f3->set('message', $this->f3->get('COOKIE.message'));
         $this->f3->set('COOKIE.message', '');
     }
     if ($this->f3->get('COOKIE.messagetype')) {
         $this->f3->set('messagetype', $this->f3->get('COOKIE.messagetype'));
         $this->f3->set('COOKIE.messagetype', '');
     }
 }
예제 #3
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) {