/** * 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); }
public function main() { $monthlyWorkingTime = Workday::groupedByMonth('F'); $monthlyBalances = []; foreach ($monthlyWorkingTime as $monthName => $month) { $monthlyBalances[$monthName] = Workday::monthBalance($monthName); } return view('main', ['months' => $monthlyWorkingTime, 'monthlyBalances' => $monthlyBalances]); }
public function destroy($id) { $responseMessage = ['id' => $id, 'success' => false]; if (!($workday = Workday::find($id))) { return response()->json($responseMessage); } $workday->delete(); $responseMessage['success'] = true; return response()->json($responseMessage); }
public function isWorkday($timestamp) { $workday = Workday::where('date', date('Y-m-d', $timestamp))->first(); if ($workday) { return $workday->isworkday; } if (getdate($timestamp)['weekday'] != 'Sunday' && getdate($timestamp)['weekday'] != 'Saturday') { $isWorkday = true; } else { $isWorkday = false; } return $isWorkday; }