- Implemented LecturerEdit and LecturerIndex components for managing lecturers. - Created StudentCreate and StudentEdit components for adding and editing students. - Developed StudentIndex component for listing students with search and pagination. - Added department and user types for better type safety. - Updated routes for lecturers and students, including reset password functionality. - Removed AppSidebar from dashboard for a cleaner layout.
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Users;
|
|
|
|
use App\Enums\Gender;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class AdministratorRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$userId = $this->route('user')?->id;
|
|
|
|
return [
|
|
'username' => [
|
|
'required',
|
|
'string',
|
|
'max:20',
|
|
'min:5',
|
|
'alpha_dash',
|
|
$userId === null
|
|
? Rule::unique('users')
|
|
: Rule::unique('users')->ignore($userId),
|
|
],
|
|
'email' => [
|
|
'required',
|
|
'string',
|
|
'email',
|
|
'max:255',
|
|
$userId === null
|
|
? Rule::unique('users')
|
|
: Rule::unique('users')->ignore($userId),
|
|
],
|
|
'role' => ['required', 'string', Rule::in(['staff-admin', 'staff-keuangan'])],
|
|
|
|
// Profile
|
|
'full_name' => ['required', 'string', 'max:150'],
|
|
'phone_number' => ['required', 'string', 'max:20'],
|
|
'address' => ['required', 'string'],
|
|
'gender' => ['required', 'string', Rule::in(array_values(Gender::cases()))],
|
|
'birth_date' => ['required', 'date'],
|
|
'birth_place' => ['required', 'string', 'max:100'],
|
|
];
|
|
}
|
|
}
|