- Remove unused FeaturesController (empty stubs, no routes) - Remove ConvertSpatialFile CLI command (unused; service used in LayerManager) - Remove MigrateGeojsonToFeatures CLI command (one-shot migration, not referenced) - Remove .claude/worktrees/ (11 old agent worktrees from June) - Apply Laravel Pint formatting across 219 files (style only, no functional changes) Tests: 101 passing (319 assertions) API routes: unchanged (8 routes intact)
39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Inspection;
|
|
use App\Models\Issue;
|
|
use App\Models\Project;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ProjectReportController extends Controller
|
|
{
|
|
public function show(Project $project)
|
|
{
|
|
$user = Auth::user();
|
|
if (! $user->can('manage all') && ! $project->users()->where('user_id', $user->id)->exists()) {
|
|
abort(403);
|
|
}
|
|
|
|
$phases = $project->phases()
|
|
->with(['layers.features.inspections', 'layers.features.issues'])
|
|
->orderBy('order')
|
|
->get();
|
|
|
|
$stats = [
|
|
'total_features' => $phases->flatMap(fn ($p) => $p->layers)->flatMap(fn ($l) => $l->features)->count(),
|
|
'completed_features' => $phases->flatMap(fn ($p) => $p->layers)->flatMap(fn ($l) => $l->features)->where('status', 'completed')->count(),
|
|
'total_inspections' => Inspection::where('project_id', $project->id)->count(),
|
|
'open_issues' => Issue::where('project_id', $project->id)->where('status', 'open')->count(),
|
|
'avg_progress' => round($phases->avg('progress_percent') ?? 0),
|
|
];
|
|
|
|
$pdf_data = compact('project', 'phases', 'stats');
|
|
|
|
// Use Blade to render HTML, then return as "print" view
|
|
// (barryvdh/laravel-dompdf is not installed, so we render a printable HTML page)
|
|
return view('reports.project-report', $pdf_data);
|
|
}
|
|
}
|