36 lines
1021 B
PHP
36 lines
1021 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\AttendanceCommentTemplate;
|
|
|
|
use App\Http\Requests\ApiFormRequest;
|
|
|
|
class StoreAttendanceCommentTemplateRequest extends ApiFormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true; // add auth/policy if needed
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'min_score' => ['required', 'integer', 'min:0', 'max:100'],
|
|
'max_score' => ['required', 'integer', 'min:0', 'max:100', 'gte:min_score'],
|
|
'template_text' => ['required', 'string', 'max:5000'],
|
|
'is_active' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if ($this->has('is_active')) {
|
|
$this->merge([
|
|
'is_active' => filter_var($this->input('is_active'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
|
|
?? $this->input('is_active'),
|
|
]);
|
|
} else {
|
|
$this->merge(['is_active' => true]);
|
|
}
|
|
}
|
|
}
|