/** * [postReturnRequest description] * * @param integer $id return_request_id * @return Redirect */ public function postReturnRequest($return_id) { $return = app('OrderRepo')->getReturnSchedule(['id' => $return_id, 'status' => 0]); $data = ['return' => $return]; \Mail::send('emails.return_schedule_confirm', $data, function ($message) use($return) { $user = $return['order']['user']; $message->to($user['email'], $user['name'])->subject('[ThankSpace] Confirmation return #' . GetLastInvoiceOrder($return['order']['id'])->code . ' di ThankSpace'); }); // update the return schedule \ReturnSchedule::where('id', $return_id)->update(['status' => 1]); return Redirect::route('admin.returnRequest')->withMessage(['success' => 'Return request telah sukses terkonfirmasi']); }
/** * For return schedule set returned for driver * * @param array $input * @return mix \Illuminate\Database\Eloquent\Model|false */ public function setReturnedSet(array $input = array()) { $confirm = \ReturnSchedule::whereIn('id', $input['return_schedule_id'])->update(['status' => 2]); if ($confirm) { $schedule = $input['return_schedule_id']; for ($i = 0; $i < count($schedule); $i++) { \OrderStuff::where('return_schedule_id', $schedule[$i])->update(['status' => 2]); $return = \ReturnSchedule::where('id', $schedule[$i])->first(); $stuff_count = \OrderStuff::where('order_id', $return->order_id)->where('status', 1)->count(); if ($stuff_count == 0) { \Order::where('id', $return->order_id)->update(['is_returned' => 1]); } } return $confirm; } else { $this->setErrors(['message' => ['ico' => 'meh', 'msg' => 'No return schedule selected', 'type' => 'error']]); return false; } }