fleetCatalogue/resources/views/vehicles/index.blade.php

71 lines
3.7 KiB
PHP
Raw Normal View History

@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') }}"
placeholder="Select Game or AppId" templateResult="true"
templateSelection="true" text="item.name + '|AppID: ' + item.appID">
<x-select-dropdown-hover alpineVariable="vehicle_class_id" placeholder="Pick a Vehicle Class..."
:enums="$vehicleClasses" functionCall="getDescription"/>
<x-select-dropdown-hover alpineVariable="brand_id" placeholder="Pick a Brand..."
:enums="$brands" functionCall="getDescription"/>
<x-select-dropdown-hover alpineVariable="fuel_type_id" placeholder="Pick a Fuel Type..."
:enums="$fuelTypes"/>
<x-select-dropdown-hover alpineVariable="vendor_id" placeholder="Pick a Vendor..."
:enums="$vendors"/>
<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
$values = [[
'image_path' => ['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')],
]];
foreach ($vehicles as $key => $vehicle) {
$values[] = [
'image_path' => ['type' => 'image', 'value' => asset('img/vehicles/' . $vehicle->getImagePath())],
'id' => ['type' => 'int', 'value' => $game->getId()],
'name' => ['type' => 'string', 'value' => $game->getName()],
'brand' => ['type' => 'string', 'value' => $brands->firstWhere('id', '=', $vehicle->getBrandId())->getName()],
'class' => ['type' => 'string', 'value' => $vehicleClasses->firstWhere('id', '=', $vehicle->getVehicleClassId())->getName()],
'storage' => ['type' => 'int', 'value' => $vehicle->getStorage()],
'fuel_type' => ['type' => 'string', 'value' => $fuelTypes->firstWhere('id', '=', $vehicle->getFuelTypeId())->getName()],
'fuel_volume' => ['type' => 'int', 'value' => $vehicle->getFuelVolume()],
'seats' => ['type' => 'int', 'value' => $vehicle->getSeats()],
'top_speed' => ['type' => 'int', 'value' => $vehicle->getTopSpeed()],
'price' => ['type' => 'int', 'value' => $vehicle->getPrice(), 'unit' => env('CURRENCY', '$')],
'vendor' => ['type' => 'string', 'value' => $vendors->firstWhere('id', '=', $vehicle->getVendorId())->getName()],
];
}
@endphp
@switch(app('request')->input('listMode'))
@case('tableHorizontal')
@case('tableVertical')
<x-table.table :mode="app('request')->input('listMode')" :values="$values" />
@break
@default
<x-grid>
@foreach($vehicles as $key => $vehicle)
<x-vehicles.card :vehicle="$vehicle"/>
@endforeach
</x-grid>
@endswitch
{{ $vehicles->links() }}
</x-layout>