39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateEmployeeRequest 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
|
|
{
|
|
$employeeId = $this->route('employee')->id;
|
|
$userId = $this->route('employee')->user_id;
|
|
|
|
return [
|
|
'name' => 'required|string|max:255',
|
|
'email' => 'required|email|unique:users,email,' . $userId,
|
|
'nip' => 'required|string|unique:employees,nip,' . $employeeId,
|
|
'position' => 'required|string',
|
|
'status' => 'required|in:PKWT,PKWTT',
|
|
'join_date' => 'required|date',
|
|
// Password opsional saat update
|
|
'password' => 'nullable|string|min:8',
|
|
];
|
|
}
|
|
}
|