![]() 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/ts.corals.io/corals-api/Corals/modules/Timesheet/Http/Requests/ |
<?php namespace Corals\Modules\Timesheet\Http\Requests; use Corals\Foundation\Http\Requests\BaseRequest; use Corals\Modules\Timesheet\Models\Expense; class ExpenseRequest extends BaseRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $this->setModel(Expense::class); return $this->isAuthorized(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $this->setModel(Expense::class); $rules = parent::rules(); if ($this->isUpdate() || $this->isStore()) { $rules = array_merge($rules, [ 'category_id' => 'required', 'project_id' => 'required_if:billable,1', 'notes' => 'required', 'status' => 'required', 'expense_date' => 'required', 'amount' => 'numeric|gt:0|required|min:0', 'billable' => '', 'payment_method' => 'required', 'currency' => 'required', ]); } if ($this->isStore()) { $rules = array_merge($rules, [ ]); } if ($this->isUpdate()) { $rules = array_merge($rules, [ ]); } return $rules; } public function attributes() { $attributes = [ 'notes' => trans('Timesheet::attributes.expense.notes'), 'expense_date' => trans('Timesheet::attributes.expense.expense_date'), 'amount' => trans('Timesheet::attributes.expense.amount'), 'billable' => trans('Timesheet::attributes.expense.billable'), ]; return $attributes; } public function messages() { return [ 'project_id.required_if' => 'The project field is required when billable is selected.' ]; } }