40 lines
973 B
PHP
40 lines
973 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Livewire;
|
||
|
|
|
||
|
|
use Livewire\Component;
|
||
|
|
use App\Models\Phase;
|
||
|
|
|
||
|
|
class PhaseProgress extends Component
|
||
|
|
{
|
||
|
|
public Phase $phase;
|
||
|
|
public $progress;
|
||
|
|
public $comment = '';
|
||
|
|
|
||
|
|
public function mount(Phase $phase)
|
||
|
|
{
|
||
|
|
$this->phase = $phase;
|
||
|
|
$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');
|
||
|
|
}
|
||
|
|
}
|