first commit
This commit is contained in:
40
app/Http/Requests/ReportingCycleRequest.php
Normal file
40
app/Http/Requests/ReportingCycleRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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)',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user