![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/dceprojects.corals.io/Corals/modules/Timesheet/Http/Requests/ |
<?php namespace Corals\Modules\Timesheet\Http\Requests; use Corals\Foundation\Http\Requests\BaseRequest; use Corals\Modules\Timesheet\Models\Job; class JobRequest extends BaseRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $this->setModel(Job::class); return $this->isAuthorized(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $this->setModel(Job::class); $rules = parent::rules(); if ($this->isUpdate() || $this->isStore()) { $rules = array_merge($rules, [ 'starts_at' => 'nullable|required_with:ends_at,after:now', 'ends_at' => 'nullable|required_with:starts_at|after:starts_at', ]); } if ($this->isStore()) { $rules = array_merge($rules, [ 'title' => 'required|string', 'hours_per_employee' => 'required|gt:0', 'number' => 'nullable|string', 'departments' => 'required|array', 'departments*' => 'required|array', 'departments.*.department_code' => 'required|distinct|exists:utility_list_of_values,code', 'departments.*.hours' => 'required|numeric|gt:0', ]); } if ($this->isUpdate()) { $rules = array_merge($rules, [ 'title' => 'sometimes|required|string', 'hours_per_employee' => 'sometimes|required|gt:0', 'number' => 'nullable|string', 'departments' => 'sometimes|required|array', 'departments*' => 'required|array', 'departments.*.department_code' => 'required|distinct|exists:utility_list_of_values,code', 'departments.*.hours' => 'required|numeric|gt:0', ]); } return $rules; } public function attributes() { return [ 'departments.*.department_code' => 'department', 'departments.*.hours' => 'hours' ]; } }