feat: implement comprehensive dashboard controller and modular administrative and project management interfaces
This commit is contained in:
@@ -23,16 +23,27 @@ class ApprovalController extends Controller
|
||||
$user = $request->user();
|
||||
$tab = $request->get('tab', 'pending');
|
||||
|
||||
$isAdmin = $user->user_type === 'admin' || $user->hasRole(['Super Admin', 'admin', 'Main Contractor Admin']);
|
||||
$isApprovingRole = $isAdmin || $user->hasRole(['Project Manager', 'Contractor Admin']);
|
||||
|
||||
$query = ApprovalChain::query();
|
||||
|
||||
if ($tab === 'history') {
|
||||
$query->whereHas('steps', function ($q) use ($user) {
|
||||
$q->where('approver_id', $user->id)->where('status', '!=', 'pending');
|
||||
});
|
||||
if ($isApprovingRole) {
|
||||
$query->whereIn('status', ['approved', 'rejected']);
|
||||
} else {
|
||||
$query->whereHas('steps', function ($q) use ($user) {
|
||||
$q->where('approver_id', $user->id)->where('status', '!=', 'pending');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$query->whereHas('steps', function ($q) use ($user) {
|
||||
$q->where('approver_id', $user->id)->where('status', 'pending');
|
||||
})->whereIn('status', ['pending', 'in_review']);
|
||||
if ($isApprovingRole) {
|
||||
$query->whereIn('status', ['pending', 'in_review']);
|
||||
} else {
|
||||
$query->whereHas('steps', function ($q) use ($user) {
|
||||
$q->where('approver_id', $user->id)->where('status', 'pending');
|
||||
})->whereIn('status', ['pending', 'in_review']);
|
||||
}
|
||||
}
|
||||
|
||||
$chains = $query->with(['steps.approver:id,name', 'initiator:id,name'])
|
||||
|
||||
Reference in New Issue
Block a user