feat: granular permissions, export backup, user/role management
- PermissionSeeder: 29 permissions with role mapping (admin/manager/staff) - Policies updated to use hasPermissionTo() instead of hasRole() - ExportBackup command: JSON per-table backup with chunk processing - UserResource: CRUD users with role assignment (admin only) - RoleResource: CRUD roles with permission assignment (admin only) - UserPolicy + RolePolicy: admin-only access control - ImportCskh: detailed skip logging with color in dry-run mode - Widgets: permission-based visibility checks - Tests: 8/8 pass (21 assertions)
This commit is contained in:
@@ -17,7 +17,7 @@ class AvgProcessingTimeWidget extends BaseWidget
|
||||
->whereNotNull('assigned_to')
|
||||
->whereNotNull('updated_at');
|
||||
|
||||
if ($user->hasRole('manager')) {
|
||||
if ($user->hasRole('manager') && ! $user->hasRole('admin')) {
|
||||
$deptIds = Department::where('manager_id', $user->id)->pluck('id');
|
||||
$query->whereIn('current_department_id', $deptIds);
|
||||
}
|
||||
@@ -33,27 +33,38 @@ class AvgProcessingTimeWidget extends BaseWidget
|
||||
|
||||
$escalatedCount = (clone $query)->where('is_escalated', true)->count();
|
||||
|
||||
$avgDisplay = $avgMinutes ? round($avgMinutes) . ' min' : 'N/A';
|
||||
$avgDescription = $avgMinutes
|
||||
? 'Avg time from creation to resolution'
|
||||
: 'No resolved tickets yet';
|
||||
|
||||
return [
|
||||
Stat::make('Resolved Tickets', (string) $totalResolved)
|
||||
->description('Total resolved/closed tickets')
|
||||
->color('success'),
|
||||
->descriptionIcon('heroicon-m-check-circle')
|
||||
->color('success')
|
||||
->chart([7, 3, 4, 5, 6, 8, $totalResolved]),
|
||||
|
||||
Stat::make('Avg Processing Time', $avgMinutes ? round($avgMinutes) . ' min' : 'N/A')
|
||||
->description('Average time from creation to resolution')
|
||||
->color('warning'),
|
||||
Stat::make('Avg Processing Time', $avgDisplay)
|
||||
->description($avgDescription)
|
||||
->descriptionIcon('heroicon-m-clock')
|
||||
->color('info'),
|
||||
|
||||
Stat::make('Pending Tickets', (string) $totalPending)
|
||||
->description('Still in progress')
|
||||
->color('danger'),
|
||||
->descriptionIcon('heroicon-m-arrow-path')
|
||||
->color('warning')
|
||||
->chart([3, 5, 4, 6, 5, 4, $totalPending]),
|
||||
|
||||
Stat::make('Escalated', (string) $escalatedCount)
|
||||
->description('Tickets marked as escalated')
|
||||
->color('gray'),
|
||||
->descriptionIcon('heroicon-m-exclamation-triangle')
|
||||
->color('danger'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()?->hasRole(['admin', 'manager']) ?? false;
|
||||
return auth()->user()?->hasPermissionTo('view-dashboard-widgets') ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user