41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ReportingCycleRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()->can('kitaran.urus');
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$cycleId = $this->route('reporting_cycle')?->id;
|
|
|
|
return [
|
|
'renewal_year' => [
|
|
'required', 'integer', 'min:2000', 'max:2100',
|
|
Rule::unique('reporting_cycles', 'renewal_year')->ignore($cycleId),
|
|
],
|
|
'cut_off_date' => ['nullable', 'date'],
|
|
'licence_period_year' => ['required', 'integer', 'min:1', 'max:10'],
|
|
'checklist_template_id' => ['nullable', 'exists:checklist_templates,id'],
|
|
'status' => ['required', 'in:aktif,tutup'],
|
|
'catatan' => ['nullable', 'string', 'max:1000'],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'renewal_year' => 'tahun pembaharuan',
|
|
'cut_off_date' => 'tarikh tutup',
|
|
'licence_period_year' => 'tempoh lesen (tahun)',
|
|
];
|
|
}
|
|
}
|