hasRole('Admin') && !$phase->project->users()->where('user_id', $user->id)->exists()) { abort(403); } $this->phase = $phase->load('progressUpdates'); $this->progress = $phase->progress_percent; } public function updateProgressManual() { $user = Auth::user(); if (!$user->can('update progress') && !$user->hasRole('Admin')) { session()->flash('error', 'Sin permisos para actualizar el progreso.'); return; } $this->validate(['progress' => 'required|integer|min:0|max:100']); $this->phase->progress_percent = $this->progress; $this->phase->save(); $this->phase->progressUpdates()->create([ 'user_id' => auth()->id(), 'progress_percent' => $this->progress, 'comment' => $this->comment, ]); $this->dispatch('progressUpdated', $this->phase->id, $this->progress); session()->flash('message', 'Progreso actualizado'); } public function render() { return view('livewire.phase-progress'); } }