Example #1
0
 public function destroy(Request $request, $id)
 {
     empty($id) && !empty($request->input('id')) && ($id = $request->input('id'));
     $id = (array) $id;
     foreach ($id as $v) {
         $order = Order::destroy($v);
     }
     return $this->success('', count($id) > 5, compact('id'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Order::destroy($id);
     Session::flash('flash_message', 'Order deleted!');
     return redirect('admin/orders');
 }
 function orderDelete($order_id)
 {
     if (\App\Order::findOrFail($order_id)) {
         \App\Order::destroy($order_id);
         \App\Item::where('order_id', $order_id)->delete();
         return redirect("users/orders")->with('warning', 'Order deleted successfully!');
     } else {
         return redirect("users/orders")->with('error', 'Unable to find the order. Please try again.');
     }
 }
 public function deleteOrder($id)
 {
     Order::destroy($id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request)
 {
     $rp_arr = [];
     $user = \Auth::user();
     if ($user->role->name != ('admin' or 'root')) {
         // Permission denied
     } else {
         $data = $request->json()->get('data');
         $lookUpArr = [];
         for ($i = 0; $i < count($data); $i++) {
             /*$from = Carbon::parse($data[$i]['from']);
                             $to = Carbon::parse($data[$i]['to']);
                             $location_id = \App\Location::where('name', $data[$i]['location'])->first()['id'];
             
                             \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->delete();*/
             $id = $data[$i]['id'];
             $order = \App\Order::findOrFail($id);
             array_push($lookUpArr, ['from' => $order->from, 'to' => $order->to, 'location_id' => $order->location_id]);
             \App\Order::destroy($id);
         }
         $lookUpArr = array_unique($lookUpArr, SORT_REGULAR);
         foreach ($lookUpArr as $value) {
             $from = Carbon::parse($value['from']);
             $to = Carbon::parse($value['to']);
             $location_id = $value['location_id'];
             $num_of_ordered = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->count();
             $allowance = \App\Location::findOrFail($location_id)->capacity;
             if ($num_of_ordered < $allowance) {
                 if ($num_of_ordered == 0) {
                     array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '-1']);
                 } else {
                     array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '1']);
                 }
             } else {
                 array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '0']);
             }
         }
     }
     return response()->json(['data' => $rp_arr]);
 }
Example #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     Order::destroy($id);
     return redirect()->route('orders');
 }