예제 #1
0
 /**
  * Add return schedule to boxes
  */
 public function createReturnSchedule(array $input)
 {
     $input['user_id'] = !empty($input['user_id']) ? $input['user_id'] : \Auth::user()->id;
     $input['status'] = 1;
     $validation = \ReturnSchedule::validate($input, ['stuffs' => 'required|array']);
     if ($validation->fails()) {
         $this->setErrors($validation->messages()->all(':message'));
         return false;
     }
     if (!empty($input['city_id'])) {
         $input['status'] = \Auth::user()->city_id == $input['city_id'] ? 1 : 0;
     }
     $returnSchedule = \ReturnSchedule::create($input);
     if ($returnSchedule) {
         \OrderStuff::whereIn('id', $input['stuffs'])->update(['return_schedule_id' => $returnSchedule->id]);
     }
     return true;
 }