public function getIndex()
 {
     $categories = array();
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     return View::make('products.index')->with('products', Product::all())->with('categories', $categories);
 }
 public function postDestroy()
 {
     $category = Category::find(Input::get('id'));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('message', 'Category Deleted');
     }
     return Redirect::to('admin/categories/index')->with('message', 'Something went wrong, please try again!');
 }
Example #3
0
 public function __construct()
 {
     $this->beforeFilter(function () {
         View::share('catnav', Category::all());
     });
 }
Example #4
0
 public function getCategory($cat_id)
 {
     return View::make('store.category')->with('products', Product::where('category_id', '=', $cat_id)->paginate(6))->with('category', Category::find($cat_id));
 }