TIF_E41202420/app/Http/Requests/Employee/StatementRequest.php

45 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Employee;
use App\Models\Statement;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
class StatementRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'statement_code' => ['required', 'string', 'max:255'],
'statement' => ['required', 'string', 'max:255', Rule::unique(Statement::class)->ignore($this->statements)],
];
}
public function messages(): array
{
return [
'statement_code.required' => 'Kode statement harus diisi.',
'statement_code.string' => 'Kode statement harus berupa teks.',
'statement_code.max' => 'Kode statement tidak boleh lebih dari 255 karakter.',
'statement.required' => 'Statemen harus diisi.',
'statement.string' => 'Statemen harus berupa teks.',
'statement.max' => 'Statemen tidak boleh lebih dari 255 karakter.',
'statement.unique' => 'Statemen telah digunakan.',
];
}
}