sackey e839d40a99
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
Initial commit
2025-07-30 17:15:50 +00:00

47 lines
1.2 KiB
PHP

<?php
namespace App\Livewire\ServiceOrders;
use Livewire\Component;
use App\Models\ServiceOrder;
class Show extends Component
{
public ServiceOrder $serviceOrder;
public function mount(ServiceOrder $serviceOrder)
{
$this->serviceOrder = $serviceOrder->load([
'customer',
'vehicle',
'assignedTechnician',
'serviceItems',
'parts',
'inspections',
'appointments'
]);
}
public function updateStatus($status)
{
$this->serviceOrder->status = $status;
if ($status === 'in_progress' && !$this->serviceOrder->started_at) {
$this->serviceOrder->started_at = now();
} elseif ($status === 'completed' && !$this->serviceOrder->completed_at) {
$this->serviceOrder->completed_at = now();
}
$this->serviceOrder->save();
session()->flash('success', 'Service order status updated successfully!');
// Refresh the model
$this->mount($this->serviceOrder);
}
public function render()
{
return view('livewire.service-orders.show');
}
}