Exemplo n.º 1
0
 public function __construct()
 {
     $this->data['categories'] = Products\Category::where('status', '!=', 0)->GetNested();
     $this->data['products'] = Products\Product::where('product_status', '!=', 0)->take(shopOpt('product_perpage_front'))->get();
     $this->data['mtop'] = Page\Page::where('page_status', 1)->where('page_position', '=', 'top')->GetNested('top');
     $this->data['mbottom'] = Page\Page::where('page_status', 1)->where('page_position', '=', 'bottom')->GetNested('bottom');
     $this->data['slideshow'] = Widget\Slideshow::where('ss_status', 1)->orderBy('ss_order')->get();
 }
Exemplo n.º 2
0
 private function setOrder($data)
 {
     $order = [];
     $total = 0;
     for ($i = 1; $i <= $data['itemCount']; $i++) {
         $order['shipping'] = ['service' => isset($data['service']) ? $data['service'] : '', 'city' => isset($data['city']) ? $data['city'] : Auth::user()->city, 'province' => isset($data['province']) ? $data['city'] : Auth::user()->province, 'fee' => $data['shipping']];
         $product_id = explode(',', str_replace(' ', '', $data['item_options_' . $i]));
         $pro_id = preg_replace("/[^0-9,.]/", "", $product_id[0]);
         unset($product_id[0]);
         $options = implode(',', $product_id);
         $order['product'][] = ['id' => $pro_id, 'product_img' => Products\Product::find($pro_id)->image->first() ? Products\Product::find($pro_id)->image->first()->path_thumb : '', 'product_name' => $data['item_name_' . $i], 'product_qty' => $data['item_quantity_' . $i], 'product_price' => $data['item_price_' . $i], 'product_options' => $options, 'product_tprice' => $data['item_quantity_' . $i] * $data['item_price_' . $i]];
         $total += $data['item_quantity_' . $i] * $data['item_price_' . $i];
         $order['sub_total'] = $total;
     }
     $order['total'] = $order['sub_total'] + $order['shipping']['fee'];
     return $order;
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     if (!Entrust::can('product-delete')) {
         return response()->json(['success' => FALSE]);
     }
     $product = Product::find($id);
     $product->attribute()->delete();
     if (count($product->image) > 0) {
         foreach ($product->image as $image) {
             if (Storage::exists('products/thumb/' . $image->img_name)) {
                 Storage::delete('products/thumb/' . $image->img_name);
             }
             if (Storage::exists('products/full/' . $image->img_name)) {
                 Storage::delete('products/full/' . $image->img_name);
             }
         }
         $product->image()->delete();
     }
     if ($product->delete()) {
         return response()->json(['success' => TRUE]);
     }
 }