Beispiel #1
0
 public static function ProductPrices()
 {
     $param = func_get_args();
     if (@$param[0] != null) {
         if ($param[0] == 'todays') {
             $orders = Order::where('days', date('Y-m-d'))->get();
         } else {
             if ($param[0] == 'months') {
                 $orders = Order::where('months', date('Y-m'))->get();
             } else {
                 if ($param[0] == 'years') {
                     $orders = Order::where('years', date('Y'))->get();
                 } else {
                     $orders = Order::all();
                 }
             }
         }
         if (count($orders) > 0) {
             $priceall = 0;
             foreach ($orders as $order) {
                 $otplist = OrderToProduct::where('order_id', $order->id)->get();
                 foreach ($otplist as $value) {
                     $priceall += $value->number * self::ProductInfo($value->product_id, 'price');
                 }
             }
             return $priceall;
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
 public function getDelete($id)
 {
     $order = Order::find($id);
     if (!$order) {
         return Redirect::to('order');
     }
     $lists = OrderToProduct::where('order_id', $order->id)->get();
     if (count($lists) > 0) {
         foreach ($lists as $item) {
             $item->delete();
         }
     }
     $order->delete();
     if (!$order->delete()) {
         return Redirect::to('order')->with(['message' => 'true', 'title' => 'Tebrikler!', 'text' => 'Sipariş kaydı başarıyla silindi.', 'type' => 'success']);
     } else {
         return Redirect::back()->with(['message' => 'true', 'title' => 'Hata!', 'text' => 'Sipariş kaydı silinemedi! Lütfen daha sonra tekrar deneyiniz.', 'type' => 'error']);
     }
 }