feat: Implement admin role and permission management, employee management APIs, and user profile extensions.

This commit is contained in:
pbao9
2026-03-10 11:43:19 +07:00
parent a70900f542
commit cf0f2cf686
14 changed files with 924 additions and 187 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class EmployeeRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$employeeId = $this->route('id');
$rules = [
'firstname' => 'required|string|max:255',
'lastname' => 'required|string|max:255',
'username' => ['required', 'string', 'max:255', Rule::unique('user', 'username')->ignore($employeeId)],
'email' => ['required', 'email', 'max:255', Rule::unique('user', 'email')->ignore($employeeId)],
'role' => ['required', Rule::in(['Administrator', 'Sale', 'IT', 'Customer Service', 'Marketing'])],
'phone' => 'nullable|string|max:20',
'birthday' => 'nullable|date',
'address' => 'nullable|string|max:500',
];
if ($this->isMethod('POST')) {
$rules['password'] = 'required|string|min:8|confirmed';
} else {
$rules['password'] = 'nullable|string|min:8|confirmed';
}
return $rules;
}
}