public function deletefile($file_id, $order_id, $type)
 {
     OrderFile::find($file_id)->delete();
     if ($type == 'delay') {
         $delay_order = DelayOrders::with('files', 'history')->findOrFail($order_id);
         return view('orders::delay.edit', compact('delay_order'));
     } elseif ($type == 'withdraw') {
         $withdraw_order = WithdrawOrders::with('files', 'history')->findOrFail($order_id);
         return view('orders::withdraw.edit', compact('withdraw_order'));
     }
 }
Example #2
0
 public function change(Request $request)
 {
     $withdraw_order = Withdraw::findOrFail($request->order_id);
     $withdraw_order->state = $request->state;
     $withdraw_order->save();
     //save in history
     $order_history = new Orderhistory();
     $order_history->ref_key = 'order_withdraws';
     $order_history->ref_value = $request->order_id;
     $order_history->state = $request->state;
     $order_history->note = $request->note;
     $order_history->created_by = user()->id;
     $order_history->save();
     // accept state
     if ($request->state == 'قبول') {
         $withdraw_order->refund_state = $request->input('refund_state');
         $withdraw_order->save();
         //event
         //drop subject
         // credit
         //change student study state
         //add student history
         event(new WithdrawOrderAccepted($withdraw_order));
         //end event
     }
     $withdraw_order = Withdraw::with('student', 'files', 'history', 'history.user')->findOrFail($request->order_id);
     return redirect()->route('withdraw.show', $withdraw_order->id)->with('success', trans('orders::order.change_success'));
 }