Dashboard con stats, LayerUpload funcional, PhaseProgress eager-loading, README actualizado
This commit is contained in:
+35
-1
@@ -34,7 +34,41 @@ Route::middleware(['auth'])->group(function () {
|
||||
|
||||
// Dashboard principal (vista con estadísticas y lista de proyectos)
|
||||
Route::get('/dashboard', function () {
|
||||
return view('dashboard');
|
||||
$user = \Illuminate\Support\Facades\Auth::user();
|
||||
|
||||
$projects = \App\Models\Project::accessibleBy($user)
|
||||
->withCount('phases')
|
||||
->with('phases')
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$allProjects = \App\Models\Project::accessibleBy($user);
|
||||
$activeProjects = (clone $allProjects)->where('status', 'in_progress');
|
||||
$totalPhases = \App\Models\Phase::whereIn('project_id', (clone $allProjects)->pluck('id'))->count();
|
||||
$totalFeatures = \App\Models\Feature::whereIn('layer_id', function($q) use ($allProjects) {
|
||||
$q->select('id')->from('layers')->whereIn('project_id', (clone $allProjects)->pluck('id'));
|
||||
})->count();
|
||||
|
||||
$globalProgress = \App\Models\Phase::whereIn('project_id', (clone $allProjects)->pluck('id'))->avg('progress_percent') ?? 0;
|
||||
|
||||
$inspections = \App\Models\Inspection::whereIn('project_id', (clone $allProjects)->pluck('id'))
|
||||
->with(['template', 'feature'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
return view('dashboard', [
|
||||
'stats' => [
|
||||
'active_projects' => $activeProjects->count(),
|
||||
'total_projects' => $allProjects->count(),
|
||||
'total_phases' => $totalPhases,
|
||||
'total_features' => $totalFeatures,
|
||||
'global_progress' => round($globalProgress),
|
||||
],
|
||||
'recentProjects' => $projects,
|
||||
'recentInspections' => $inspections,
|
||||
]);
|
||||
})->name('dashboard');
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user