2023-10-09 18:19:38 +00:00
@ php
use App\Models\Vehicle ;
/** @var Vehicle $vehicle */
@ endphp
< x - layout title = " { { __('Vehicles') }} " >
< x - slot : breadcrumb >
{{ Breadcrumbs :: render ( 'vehicles' ) }}
</ x - slot : breadcrumb >
< x - slot name = " header " >
< h2 > {{ __ ( 'Vehicles' ) }} </ h2 >
< x - searchbar - select2 post = " { { route('vehicles') }} " inputClasses = " w-[20rem] "
autocomplete = " { { route('vehicles.autocomplete') }} "
2023-10-18 15:47:33 +00:00
placeholder = " Select Vehicle " templateResult = " true "
templateSelection = " true " text = " item.vehicle_name " >
2023-10-09 18:19:38 +00:00
< x - select - dropdown - hover alpineVariable = " vehicle_class_id " placeholder = " Pick a Vehicle Class... "
2023-10-14 10:45:53 +00:00
: enums = " $vehicleClasses " functionCall = " getVehicleClassName " />
2023-10-09 18:19:38 +00:00
< x - select - dropdown - hover alpineVariable = " brand_id " placeholder = " Pick a Brand... "
2023-10-14 10:45:53 +00:00
: enums = " $brands " functionCall = " getBrandName " />
2023-10-09 18:19:38 +00:00
< x - select - dropdown - hover alpineVariable = " fuel_type_id " placeholder = " Pick a Fuel Type... "
2023-10-14 10:45:53 +00:00
: enums = " $fuelTypes " functionCall = " getFuelTypeName " />
2023-10-09 18:19:38 +00:00
< x - select - dropdown - hover alpineVariable = " vendor_id " placeholder = " Pick a Vendor... "
2023-10-14 10:45:53 +00:00
: enums = " $vendors " functionCall = " getVendorName " />
2023-10-09 18:19:38 +00:00
< x - select - dropdown - hover alpineVariable = " listMode " : enums = " ['gridCards', 'tableHorizontal', 'tableVertical'] " placeholder = " Pick a display mode for the list... " default = " gridCards " />
</ x - searchbar - select2 >
</ x - slot >
@ php
2023-10-14 10:45:53 +00:00
$fields = explode ( ',' , env ( 'FIELDS' , '' ));
$headerValues = [
'image' => [ 'type' => 'string' , 'value' => __ ( 'Photo' ),],
'id' => [ 'type' => 'string' , 'value' => __ ( 'Id' )],
'name' => [ 'type' => 'string' , 'value' => __ ( 'Name' )],
'brand' => [ 'type' => 'string' , 'value' => __ ( 'Brand' )],
'class' => [ 'type' => 'string' , 'value' => __ ( 'Class' )],
'storage' => [ 'type' => 'string' , 'value' => __ ( 'Storage' )],
'fuel_type' => [ 'type' => 'string' , 'value' => __ ( 'Fuel Type' )],
'fuel_volume' => [ 'type' => 'string' , 'value' => __ ( 'Fuel Volume' )],
'seats' => [ 'type' => 'string' , 'value' => __ ( 'Seats' )],
'top_speed' => [ 'type' => 'string' , 'value' => __ ( 'Top Speed' )],
'price' => [ 'type' => 'string' , 'value' => __ ( 'Price' )],
'vendor' => [ 'type' => 'string' , 'value' => __ ( 'Vendor' )],
];
$values = [];
foreach ( $fields as $field ) {
$values [ 0 ][ $field ] = $headerValues [ $field ];
}
$index = 0 ;
2023-10-09 18:19:38 +00:00
foreach ( $vehicles as $key => $vehicle ) {
2023-10-14 10:45:53 +00:00
$index ++ ;
$fieldValues = [
'image' => [ 'type' => 'image' , 'value' => asset ( 'img/vehicles/' . $vehicle -> getVehicleId () . '.png' )],
'id' => [ 'type' => 'int' , 'value' => $vehicle -> getVehicleId ()],
'name' => [ 'type' => 'string' , 'value' => $vehicle -> getVehicleName ()],
'brand' => [ 'type' => 'string' , 'value' => $brands -> firstWhere ( 'brand_id' , '=' , $vehicle -> getBrandId ()) -> getBrandName ()],
'class' => [ 'type' => 'string' , 'value' => $vehicleClasses -> firstWhere ( 'vehicle_class_id' , '=' , $vehicle -> getVehicleClassId ()) -> getVehicleClassName ()],
'storage' => [ 'type' => 'int' , 'value' => $vehicle -> getVehicleStorage ()],
'fuel_type' => [ 'type' => 'string' , 'value' => $fuelTypes -> firstWhere ( 'fuel_type_id' , '=' , $vehicle -> getFuelTypeId ()) -> getFuelTypeName ()],
'fuel_volume' => [ 'type' => 'int' , 'value' => $vehicle -> getVehicleFuelVolume (), 'unit' => env ( 'FUEL_VOLUME_UNIT' , 'l' )],
'seats' => [ 'type' => 'int' , 'value' => $vehicle -> getVehicleSeats ()],
'top_speed' => [ 'type' => 'int' , 'value' => $vehicle -> getVehicleTopSpeed (), 'unit' => env ( 'SPEED_UNIT' , 'km/h' )],
'price' => [ 'type' => 'int' , 'value' => $vehicle -> getVehiclePrice (), 'unit' => env ( 'CURRENCY' , '$' )],
'vendor' => [ 'type' => 'string' , 'value' => $vendors -> firstWhere ( 'vendor_id' , '=' , $vehicle -> getVendorId ()) -> getVendorName ()],
];
foreach ( $fields as $field ) {
$values [ $index ][ $field ] = $fieldValues [ $field ];
}
2023-10-09 18:19:38 +00:00
}
@ endphp
2023-10-14 10:45:53 +00:00
@ switch ( app ( 'request' ) -> input ( 'listMode' ) ? ? env ( 'DEFAULT_DISPLAY_MODE' ))
2023-10-09 18:19:38 +00:00
@ case ( 'tableHorizontal' )
@ case ( 'tableVertical' )
2023-10-14 10:45:53 +00:00
< x - table . table : mode = " app('request')->input('listMode') ?? env('DEFAULT_DISPLAY_MODE') " : values = " $values " />
2023-10-09 18:19:38 +00:00
@ break
@ default
< x - grid >
@ foreach ( $vehicles as $key => $vehicle )
2023-10-14 10:45:53 +00:00
< x - vehicles . card : vehicle = " $vehicle "
: brand = " $brands->firstWhere ('brand_id', '=', $vehicle->getBrandId ())->getBrandName() "
: class = " $vehicleClasses->firstWhere ('vehicle_class_id', '=', $vehicle->getVehicleClassId ())->getVehicleClassName() "
: vendor = " $vendors->firstWhere ('vendor_id', '=', $vehicle->getVendorId ())->getVendorName() "
: fuel - type = " $fuelTypes->firstWhere ('fuel_type_id', '=', $vehicle->getFuelTypeId ())->getFuelTypeName() " />
2023-10-09 18:19:38 +00:00
@ endforeach
</ x - grid >
@ endswitch
{{ $vehicles -> links () }}
</ x - layout >