- Implemented dashboard view with vehicle stats, active services, recent activity, and upcoming appointments. - Created estimates view with filtering options and a list of service estimates. - Developed invoices view to manage service invoices and payment history with filtering. - Added vehicles view to display registered vehicles and their details. - Built work orders view to track the progress of vehicle services with filtering and detailed information.
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Customers;
|
|
|
|
use App\Models\Customer;
|
|
use Livewire\Component;
|
|
|
|
class Show extends Component
|
|
{
|
|
public Customer $customer;
|
|
public $stats = [];
|
|
|
|
public function mount(Customer $customer)
|
|
{
|
|
$this->customer = $customer->load([
|
|
'user',
|
|
'vehicles.jobCards',
|
|
'serviceOrders.assignedTechnician',
|
|
'appointments'
|
|
]);
|
|
|
|
$this->loadStats();
|
|
}
|
|
|
|
private function loadStats()
|
|
{
|
|
$this->stats = [
|
|
'total_vehicles' => $this->customer->vehicles->count(),
|
|
'total_service_orders' => $this->customer->serviceOrders->count(),
|
|
'total_appointments' => $this->customer->appointments->count(),
|
|
'active_job_cards' => $this->customer->vehicles->sum(function($vehicle) {
|
|
return $vehicle->jobCards->where('status', '!=', 'completed')->count();
|
|
}),
|
|
'completed_services' => $this->customer->serviceOrders->where('status', 'completed')->count(),
|
|
'total_spent' => $this->customer->serviceOrders->where('status', 'completed')->sum('total_amount'),
|
|
];
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.customers.show');
|
|
}
|
|
}
|