Files
construprogress/app/Livewire/PhaseProgress.php
T

42 lines
1.0 KiB
PHP
Raw Normal View History

2026-05-07 23:31:33 +02:00
<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\Attributes\Layout;
2026-05-07 23:31:33 +02:00
use App\Models\Phase;
#[Layout('layouts.app')]
2026-05-07 23:31:33 +02:00
class PhaseProgress extends Component
{
public Phase $phase;
public $progress;
public $comment = '';
public function mount(Phase $phase)
{
$this->phase = $phase->load('progressUpdates');
2026-05-07 23:31:33 +02:00
$this->progress = $phase->progress_percent;
}
public function updateProgressManual()
{
$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');
}
}