-
app/Http/Controllers/ProjectsController.php
Open in GitHubuse App\Models\Project; class ProjectsController extends Controller { // public function show(Project $project) { $tasks = $project->tasks->count(); if ($tasks === 0) { $completionPercentage = 0; } else { $completedTasks = $project->tasks()->whereHas('status', function ($q) { $q->where('title', 'closed'); })->count(); $completionPercentage = round($completedTasks / $tasks * 100); } // } // }