VideoProject::withCount([ 'steps', 'steps as completed_steps_count' => fn ($q) => $q->whereIn('status', ['completed', 'skipped']), ]) ->with(['steps' => fn ($q) => $q->whereNotIn('status', ['completed', 'skipped'])->orderBy('order')->limit(1)]) ->orderByDesc('created_at') ->get(), ]); } public function create(): void { $this->title = ''; $this->description = null; $this->resetValidation(); $this->showForm = true; } public function save(): void { $validated = $this->validate([ 'title' => ['required', 'string', 'max:255'], 'description' => ['nullable', 'string'], ]); $project = VideoProject::create($validated); $this->showForm = false; $this->redirect(route('video-projects.show', $project), navigate: true); } public function delete(int $id): void { VideoProject::findOrFail($id)->delete(); } }