예제 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show(Order $order)
 {
     $user = Sentinel::findById($order->user_id);
     $unit = Unit::all();
     $baskets = $user->baskets->where('order_id', $order->id);
     return view('cart.history', compact('order', 'baskets', 'unit'));
 }
예제 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, Model $objects)
 {
     if ($request->ajax()) {
         return $this->responseAnswer(true, Model::all());
     } else {
         return view('admin.unit.list', ['objects' => $objects->paginate(10)]);
     }
 }
예제 #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $totalprice = 0;
     $user = Sentinel::getUser();
     $num = $user->baskets->where('order_id', 0)->count();
     $items = Basket::select(DB::raw('products.name,products.pic,baskets.id,baskets.count,baskets.unit_id,baskets.price,baskets.product_id, baskets.price*baskets.count as total'))->join('products', 'products.id', '=', 'baskets.product_id')->where('baskets.user_id', '=', $user->id)->where('baskets.order_id', 0)->get();
     foreach ($items as $item) {
         $totalprice += $item->total;
     }
     return response()->json(['result' => true, 'count' => $num, 'cartdata' => view('cart', array('items' => $items, 'total' => $totalprice, 'unit' => Unit::all()))->render()]);
 }
예제 #4
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //dd($id);
     //
     //
     $brands = Brand::all();
     $categories = Category::all();
     $product = Product::with('description')->find($id);
     $prices = $product->prices;
     //$mrps = Mrp::with('unit')->where('product_id', $id)->get();
     //dd($mrp);
     $images = $product->images;
     $units = Unit::all();
     return view('admin/product/edit', compact('product', 'categories', 'brands', 'images', 'units', 'prices'));
 }
예제 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $object = Model::find($id);
     if ($object) {
         $params = $request->only('img', 'slider_img', 'ru_slider', 'en_slider', 'ua_slider', 'product_category_id', 'unit_id', 'ru_title', 'ru_description', 'ru_file', 'ru_seo_title', 'ru_seo_keywords', 'ru_seo_description', 'en_title', 'en_description', 'en_file', 'en_seo_title', 'en_seo_keywords', 'en_seo_description', 'ua_title', 'ua_description', 'ua_file', 'ua_seo_title', 'ua_seo_keywords', 'ua_seo_description');
         $filter = $object->validator($params, ['ru_title' => 'required|min:2|max:150|unique:products,ru_title,' . $id, 'en_title' => 'required|min:2|max:150|unique:products,en_title,' . $id, 'ua_title' => 'required|min:2|max:150|unique:products,ua_title,' . $id]);
         if ($filter->fails()) {
             if ($request->ajax()) {
                 return $this->responseAnswer(true, $params, $filter->errors());
             } else {
                 $error = $filter->errors()->toArray();
                 $params['id'] = $id;
                 $params['img'] = $object->img;
                 $categories = ProductCategory::all();
                 $units = Unit::all();
                 $options = $object->options();
                 return view('admin.product.edit', ['input' => $params, 'error' => $error, 'categories' => $categories, 'units' => $units, 'options' => $options]);
             }
         }
         if ($request->hasFile('img')) {
             $params['img'] = $this->upload('img');
             if ($object->img && file_exists(public_path() . DS . 'uploads' . DS . 'product' . DS . $object->img)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'product' . DS . $object->img);
             }
         } else {
             unset($params['img']);
         }
         if ($request->hasFile('slider_img')) {
             $params['slider_img'] = $this->upload('slider_img');
             if ($object->slider_img && file_exists(public_path() . DS . 'uploads' . DS . 'product' . DS . $object->slider_img)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'product' . DS . $object->slider_img);
             }
         } else {
             unset($params['slider_img']);
         }
         if ($request->hasFile('ru_file')) {
             $params['ru_file'] = $this->uploadPdf('ru_file');
             if ($object->ru_file && file_exists(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->ru_file)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->ru_file);
             }
         } else {
             unset($params['ru_file']);
         }
         if ($request->hasFile('en_file')) {
             $params['en_file'] = $this->uploadPdf('en_file');
             if ($object->en_file && file_exists(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->en_file)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->en_file);
             }
         } else {
             unset($params['en_file']);
         }
         if ($request->hasFile('ua_file')) {
             $params['ua_file'] = $this->uploadPdf('ua_file');
             if ($object->ua_file && file_exists(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->ua_file)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'product' . DS . 'pdfs' . DS . $object->ua_file);
             }
         } else {
             unset($params['ua_file']);
         }
         $params['on_top'] = $request->has('on_top');
         $params['alias'] = $this->makeAlias($params['ru_title']);
         $object->fill($params);
         $object->save();
         if ($request->ajax()) {
             return $this->responseAnswer(false, $object);
         } else {
             $categories = ProductCategory::all();
             return redirect('admin/product/' . $object->id . '/edit');
         }
     }
     if ($request->ajax()) {
         return $this->responseAnswer(true, $params, null, trans('product.bad_product'));
     } else {
         return redirect('admin/products');
     }
 }
예제 #6
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     return Unit::all();
 }