first
This commit is contained in:
36
app/Http/Requests/Admin/CreateUserRequest.php
Normal file
36
app/Http/Requests/Admin/CreateUserRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class CreateUserRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user()->isAdmin();
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255', 'unique:users,email'],
|
||||
'password' => ['required', 'confirmed', Password::min(8)->mixedCase()->numbers()],
|
||||
'role' => ['required', 'in:admin,user'],
|
||||
'department_id' => ['nullable', 'exists:departments,id'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'Nama',
|
||||
'email' => 'E-mel',
|
||||
'password' => 'Kata laluan',
|
||||
'role' => 'Peranan',
|
||||
'department_id' => 'Jabatan',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user