/**
  * Show the form for editing the specified resource.
  *
  * @param  \App\Product $product
  * @return \Illuminate\Http\Response
  */
 public function edit(Product $product)
 {
     $productVariants = Product_variant::where('product_id', $product->product_id)->get();
     $languages = Language::orderBy('order', 'asc')->get();
     $categories = Category::all();
     $discounts = Discount::all();
     $taxes = Tax::all();
     return view('intothesource.webshop.products.edit', compact('product', 'productVariants', 'languages', 'categories', 'discounts', 'taxes'));
 }
示例#2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $categories = Category::all(array('id', 'name', 'parent_id'));
     $parent_category['0'] = 'Выберите родительскую категорию';
     foreach ($categories as $key => $category) {
         if ($category->parent_id == '') {
             $parent_category[$category->id] = $category->name;
         }
     }
     $product = Product::findOrFail($id);
     $images = Image::where('prod_id', '=', $id)->get();
     $category = Category::findOrFail($product->cat_id);
     $par_cat = Category::where('id', '=', $category->parent_id)->lists('name', 'id');
     $cat = array($category->id => $category->name);
     $discounts = ProdDiscount::where('prod_id', '=', $id)->get();
     foreach ($discounts as $key => $discount) {
         $disc = Discount::where('id', '=', $discount->discount_id)->get();
         $discounts[$key]->disc_name = $disc[0]->name;
         $discounts[$key]->disc_description = $disc[0]->description;
         $disc_old[$discounts[$key]->id] = $discounts[$key]->disc_name;
     }
     $discounts_all = Discount::all(array('id', 'name', 'description'));
     //        $discounts['0'] = 'Выберите скидки';
     foreach ($discounts_all as $key => $discount_all) {
         $disc_all[$discount_all->id] = $discount_all->name;
     }
     //dd($disc_old);
     return view('products.edit', compact('par_cat', 'cat', 'parent_category', 'images', 'discounts', 'disc_old', 'disc_all'))->withProduct($product);
 }
示例#3
0
 public function getDatatable()
 {
     return Datatable::collection(Discount::all(array('id', 'name', 'description', 'percent', 'quantity')))->showColumns('id', 'name', 'description', 'percent', 'quantity')->addColumn('created', function ($model) {
         return date('d-m-Y', strtotime(".{$model->created_at}."));
     })->addColumn('actions', function ($model) {
         return '<a href="/discounts/' . $model->id . '">Просм</a> |
                  <a href="/discounts/' . $model->id . '/edit" >Ред</a>';
     })->searchColumns('name', 'description', 'percent', 'quantity')->orderColumns('name', 'description', 'percent', 'quantity')->make();
 }