Exemple #1
0
 public function store()
 {
     $date = Carbon::createFromFormat('d/m/Y', Request::input('date'));
     $workday = new Workday();
     $workday->date = Request::input('date');
     $workday->arrival1 = Request::input('in1');
     $workday->leaving1 = Request::input('out1');
     $workday->arrival2 = Request::input('in2');
     $workday->leaving2 = Request::input('out2');
     $workday->arrival3 = Request::input('in3');
     $workday->leaving3 = Request::input('out3');
     $workday->user_id = Auth::user()->id;
     $workday->workload = $date->isWeekend() ? '00:00' : '08:00';
     $workday->save();
     return redirect('/')->with(['messages' => [['type' => 'success', 'text' => 'Workday time successfully registered!']]]);
 }
Exemple #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $this->checkParametersEmpty();
     $attributes = array_get($this->getDocument(), 'data.attributes', []);
     /** @var \Illuminate\Validation\Validator $validator */
     $rules = ['date' => 'required', 'arrival1' => 'required', 'leaving1' => 'required'];
     /** @noinspection PhpUndefinedClassInspection */
     $validator = \Validator::make($attributes, $rules);
     if ($validator->fails()) {
         throw new ValidationException($validator);
     }
     $workday = new Workday();
     $workday->user_id = Auth::user()->id;
     $workday->fill($attributes);
     $workday->save();
     return $this->getCreatedResponse($workday);
 }