feat: implement comprehensive dashboard controller and modular administrative and project management interfaces
This commit is contained in:
@@ -97,7 +97,7 @@ class UserController extends Controller
|
||||
'company_name' => ['nullable', 'string', 'max:255'],
|
||||
'contact_person' => ['nullable', 'string', 'max:255'],
|
||||
'tin_number' => ['nullable', 'string', 'max:255'],
|
||||
'spatie_role' => ['nullable', 'string', Rule::in(['Super Admin', 'Contractor', 'Project Manager', 'Designer', 'Site Technical', 'Construction Supervisor'])],
|
||||
'spatie_role' => ['nullable', 'string', Rule::in(['Super Admin', 'admin', 'Contractor', 'Contractor Admin', 'Project Manager', 'Designer', 'Site Technical', 'Construction Supervisor'])],
|
||||
]);
|
||||
|
||||
// Resolve contractor_id: contractor admins always use their own;
|
||||
@@ -123,12 +123,16 @@ class UserController extends Controller
|
||||
|
||||
// Determine Spatie role to assign
|
||||
$roleToAssign = $validated['spatie_role'] ?? $validated['user_type'];
|
||||
if ($roleToAssign === 'admin') {
|
||||
$roleToAssign = 'Super Admin';
|
||||
if ($roleToAssign === 'Contractor Admin') {
|
||||
$roleToAssign = 'Contractor';
|
||||
} elseif ($roleToAssign === 'admin') {
|
||||
$roleToAssign = 'Main Contractor Admin';
|
||||
}
|
||||
|
||||
// Explicitly assign the spatie role matching the user type or selected role
|
||||
$user->assignRole($roleToAssign);
|
||||
if ($roleToAssign) {
|
||||
$user->assignRole($roleToAssign);
|
||||
}
|
||||
|
||||
// Create profile
|
||||
$this->createProfile($user, $validated);
|
||||
|
||||
Reference in New Issue
Block a user