コード例 #1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     View::composer(['front.includes.header'], function ($view) {
         $model = new Category();
         $categories = $model->getCategoryTree();
         $view->with('categories', $categories);
     });
 }
コード例 #2
0
 public function view($slug)
 {
     $model = new Category();
     $category = $model->where('slug', '=', $slug)->get()->first();
     return view('front.category.view')->with('category', $category);
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     return redirect('/admin/category');
 }
コード例 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     //$entity = Entity::Product()->get()->first();
     $product = Product::findorfail($id);
     $productCategory = $product->category()->lists('category_id')->toArray();
     $price = $product->price()->get()->first();
     $productPrice = isset($price) ? $price->sale_price : 0;
     $categories = Category::lists('name', 'id');
     return view('admin.product.edit')->with('product', $product)->with('categories', $categories)->with('productCategory', $productCategory)->with('productPrice', $productPrice);
 }