From 801ae7c403511a3ec29e94e90e066831dffa5404 Mon Sep 17 00:00:00 2001 From: ShuriZma Date: Sat, 14 Oct 2023 12:45:53 +0200 Subject: [PATCH] various fixes add modal for images add various new .env configurations --- .env.example | 7 + app/Http/Controllers/VehicleController.php | 2 +- app/Models/Brand.php | 44 ++-- app/Models/FuelType.php | 58 ++--- app/Models/Vehicle.php | 215 +++++++++--------- app/Models/VehicleClass.php | 44 ++-- app/Models/Vendor.php | 86 +++---- ...2023_10_09_212948_make_fields_nullable.php | 1 - .../2023_10_09_234833_rename_fields.php | 97 ++++++++ public/css/app.css | 37 +++ .../views/components/image-modal.blade.php | 5 + resources/views/components/layout.blade.php | 2 +- .../views/components/layout/sidebar.blade.php | 12 +- .../views/components/table/row.blade.php | 7 +- .../views/components/vehicles/card.blade.php | 17 +- resources/views/vehicles/index.blade.php | 86 ++++--- routes/web.php | 4 + 17 files changed, 449 insertions(+), 275 deletions(-) create mode 100644 database/migrations/2023_10_09_234833_rename_fields.php create mode 100644 resources/views/components/image-modal.blade.php diff --git a/.env.example b/.env.example index c937c98..700ca9b 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,13 @@ APP_URL=http://localhost # domain of your website. might want to use "https" ins APP_COPYRIGHT=ShuriZma APP_COPYRIGHT_SINCE=2023 FOOTER_IMAGE=img/header.png # can be any image type. path should start from public/ (ex. 'img/header.png') +LANDING_PAGE=false # if set to true a landing page will be added, if false the vehicle list is the landing page + +# VEHICLE LIST +CURRENCY=$ # unit for prices etc +SPEED_UNIT=km/h # unit for top speed +FUEL_VOLUME_UNIT=l # unit for fuel volume +FIELDS=image,id,name,brand,class,storage,fuel_type,fuel_volume,seats,top_speed,price,vendor # list of fields that should be visible on the vehicle list (comma seperated). possible fields: image,id,name,brand,class,storage,fuel_type,fuel_volume,seats,top_speed,price,vendor LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null diff --git a/app/Http/Controllers/VehicleController.php b/app/Http/Controllers/VehicleController.php index a9d85b8..1dfce34 100644 --- a/app/Http/Controllers/VehicleController.php +++ b/app/Http/Controllers/VehicleController.php @@ -19,7 +19,7 @@ class VehicleController extends Controller public function index() { $vehicles = Vehicle::filter( - request(['search', 'vehicle_class_id', 'brandId', 'fuelTypeId', 'vendorId']) + request(['search', 'vehicle_class_id', 'brand_id', 'fuel_type_id', 'vendor_id']) ) ->paginate(24)->withQueryString(); diff --git a/app/Models/Brand.php b/app/Models/Brand.php index a467352..f8488ce 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -12,19 +12,19 @@ use Illuminate\Support\Carbon; /** * App\Models\Brand * - * @property int $id + * @property int $brand_id * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property string $name - * @property string|null $description - * @method static \Database\Factories\BrandFactory factory($count = null, $state = []) + * @property string $brand_name + * @property string|null $brand_description + * @method static BrandFactory factory($count = null, $state = []) * @method static Builder|Brand newModelQuery() * @method static Builder|Brand newQuery() * @method static Builder|Brand query() + * @method static Builder|Brand whereBrandDescription($value) + * @method static Builder|Brand whereBrandId($value) + * @method static Builder|Brand whereBrandName($value) * @method static Builder|Brand whereCreatedAt($value) - * @method static Builder|Brand whereDescription($value) - * @method static Builder|Brand whereId($value) - * @method static Builder|Brand whereName($value) * @method static Builder|Brand whereUpdatedAt($value) * @mixin Eloquent */ @@ -35,19 +35,19 @@ class Brand extends Model /** * @return int */ - public function getId(): int + public function getBrandId(): int { - return $this->id; + return $this->brand_id; } /** - * @param int $id + * @param int $brand_id * * @return Brand */ - public function setId(int $id): Brand + public function setBrandId(int $brand_id): Brand { - $this->id = $id; + $this->brand_id = $brand_id; return $this; } @@ -55,19 +55,19 @@ class Brand extends Model /** * @return string */ - public function getName(): string + public function getBrandName(): string { - return $this->name; + return $this->brand_name; } /** - * @param string $name + * @param string $brand_name * * @return Brand */ - public function setName(string $name): Brand + public function setBrandName(string $brand_name): Brand { - $this->name = $name; + $this->brand_name = $brand_name; return $this; } @@ -75,19 +75,19 @@ class Brand extends Model /** * @return string|null */ - public function getDescription(): ?string + public function getBrandDescription(): ?string { - return $this->description; + return $this->brand_description; } /** - * @param string|null $description + * @param string|null $brand_description * * @return Brand */ - public function setDescription(?string $description): Brand + public function setBrandDescription(?string $brand_description): Brand { - $this->description = $description; + $this->brand_description = $brand_description; return $this; } diff --git a/app/Models/FuelType.php b/app/Models/FuelType.php index 3e06a5c..3d2c07d 100644 --- a/app/Models/FuelType.php +++ b/app/Models/FuelType.php @@ -12,21 +12,21 @@ use Illuminate\Support\Carbon; /** * App\Models\FuelType * - * @property int $id + * @property int $fuel_type_id * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property string $name - * @property string|null $description - * @property float|null $price - * @method static \Database\Factories\FuelTypeFactory factory($count = null, $state = []) + * @property string $fuel_type_name + * @property string|null $fuel_type_description + * @property float|null $fuel_type_price + * @method static FuelTypeFactory factory($count = null, $state = []) * @method static Builder|FuelType newModelQuery() * @method static Builder|FuelType newQuery() * @method static Builder|FuelType query() * @method static Builder|FuelType whereCreatedAt($value) - * @method static Builder|FuelType whereDescription($value) - * @method static Builder|FuelType whereId($value) - * @method static Builder|FuelType whereName($value) - * @method static Builder|FuelType wherePrice($value) + * @method static Builder|FuelType whereFuelTypeDescription($value) + * @method static Builder|FuelType whereFuelTypeId($value) + * @method static Builder|FuelType whereFuelTypeName($value) + * @method static Builder|FuelType whereFuelTypePrice($value) * @method static Builder|FuelType whereUpdatedAt($value) * @mixin Eloquent */ @@ -37,19 +37,19 @@ class FuelType extends Model /** * @return int */ - public function getId(): int + public function getFuelTypeId(): int { - return $this->id; + return $this->fuel_type_id; } /** - * @param int $id + * @param int $fuel_type_id * * @return FuelType */ - public function setId(int $id): FuelType + public function setFuelTypeId(int $fuel_type_id): FuelType { - $this->id = $id; + $this->fuel_type_id = $fuel_type_id; return $this; } @@ -57,19 +57,19 @@ class FuelType extends Model /** * @return string */ - public function getName(): string + public function getFuelTypeName(): string { - return $this->name; + return $this->fuel_type_name; } /** - * @param string $name + * @param string $fuel_type_name * * @return FuelType */ - public function setName(string $name): FuelType + public function setFuelTypeName(string $fuel_type_name): FuelType { - $this->name = $name; + $this->fuel_type_name = $fuel_type_name; return $this; } @@ -77,19 +77,19 @@ class FuelType extends Model /** * @return string|null */ - public function getDescription(): ?string + public function getFuelTypeDescription(): ?string { - return $this->description; + return $this->fuel_type_description; } /** - * @param string|null $description + * @param string|null $fuel_type_description * * @return FuelType */ - public function setDescription(?string $description): FuelType + public function setFuelTypeDescription(?string $fuel_type_description): FuelType { - $this->description = $description; + $this->fuel_type_description = $fuel_type_description; return $this; } @@ -97,19 +97,19 @@ class FuelType extends Model /** * @return float|null */ - public function getPrice(): ?float + public function getFuelTypePrice(): ?float { - return $this->price; + return $this->fuel_type_price; } /** - * @param float|null $price + * @param float|null $fuel_type_price * * @return FuelType */ - public function setPrice(?float $price): FuelType + public function setFuelTypePrice(?float $fuel_type_price): FuelType { - $this->price = $price; + $this->fuel_type_price = $fuel_type_price; return $this; } diff --git a/app/Models/Vehicle.php b/app/Models/Vehicle.php index d94e7ef..74fe274 100644 --- a/app/Models/Vehicle.php +++ b/app/Models/Vehicle.php @@ -13,21 +13,20 @@ use Schema; /** * App\Models\Vehicle * - * @property int $id + * @property int $vehicle_id * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property string $name - * @property string|null $image_path - * @property int $storage - * @property int $fuel_volume - * @property int $seats - * @property float|null $price - * @property float|null $top_speed + * @property int $vehicle_storage + * @property int $vehicle_fuel_volume + * @property int $vehicle_seats + * @property float|null $vehicle_price + * @property float|null $vehicle_top_speed * @property int $vehicle_class_id * @property int $fuel_type_id * @property int $brand_id * @property int $vendor_id - * @method static \Database\Factories\VehicleFactory factory($count = null, $state = []) + * @method static VehicleFactory factory($count = null, $state = []) * @method static Builder|Vehicle filter(array $filters) * @method static Builder|Vehicle newModelQuery() * @method static Builder|Vehicle newQuery() @@ -35,39 +34,95 @@ use Schema; * @method static Builder|Vehicle whereBrandId($value) * @method static Builder|Vehicle whereCreatedAt($value) * @method static Builder|Vehicle whereFuelTypeId($value) - * @method static Builder|Vehicle whereFuelVolume($value) - * @method static Builder|Vehicle whereId($value) - * @method static Builder|Vehicle whereImagePath($value) * @method static Builder|Vehicle whereName($value) - * @method static Builder|Vehicle wherePrice($value) - * @method static Builder|Vehicle whereSeats($value) - * @method static Builder|Vehicle whereStorage($value) - * @method static Builder|Vehicle whereTopSpeed($value) * @method static Builder|Vehicle whereUpdatedAt($value) * @method static Builder|Vehicle whereVehicleClassId($value) + * @method static Builder|Vehicle whereVehicleFuelVolume($value) + * @method static Builder|Vehicle whereVehicleId($value) + * @method static Builder|Vehicle whereVehiclePrice($value) + * @method static Builder|Vehicle whereVehicleSeats($value) + * @method static Builder|Vehicle whereVehicleStorage($value) + * @method static Builder|Vehicle whereVehicleTopSpeed($value) * @method static Builder|Vehicle whereVendorId($value) + * @property string $vehicle_name + * @method static Builder|Vehicle whereVehicleName($value) * @mixin Eloquent */ class Vehicle extends Model { use HasFactory; - /** - * @return int - */ - public function getId(): int - { - return $this->id; + public function scopeFilter( + $query, + array $filters + ): void { + $search = $filters['search'] ?? false; + if ($search) { + $query->where('name', 'like', '%' . $search . '%'); + } + + unset($filters['search']); + + $orderByOne = $filters['orderByOne'] ?? null; + $orderByTwo = $filters['orderByTwo'] ?? null; + if (!empty($orderByOne) || !empty($orderByTwo)) { + $orderBy = ''; + if (!empty($orderByOne) && Schema::hasColumn('vehicles', $orderByOne)) { + $orderBy .= $orderByOne; + } + + if (!empty($orderByTwo) && Schema::hasColumn('vehicles', $orderByTwo)) { + $orderBy .= empty($orderBy) ? $orderByTwo : ', ' . $orderByTwo; + } + + $query->orderBy($orderBy); + } + + foreach ($filters as $field => $filter) { + if (empty($filter)) { + continue; + } + + switch ($field) { + case 'vehicle_class_id': + $query->join('vehicle_classes', 'vehicles.vehicle_class_id', '=', 'vehicle_classes.vehicle_class_id'); + $query->where('vehicle_class_name', '=', $filter); + break; + case 'brand_id': + $query->join('brands', 'vehicles.brand_id', '=', 'brands.brand_id'); + $query->where('brand_name', '=', $filter); + break; + case 'fuel_type_id': + $query->join('fuel_types', 'vehicles.fuel_type_id', '=', 'fuel_types.fuel_type_id'); + $query->where('fuel_type_name', '=', $filter); + break; + case 'vendor_id': + $query->join('vendors', 'vehicles.vendor_id', '=', 'vendors.vendor_id'); + $query->where('vendor_name', '=', $filter); + break; + default: + Schema::hasColumn('vehicles', $field); + $query->where($field, '=', $filter); + } + } } /** - * @param int $id + * @return int + */ + public function getVehicleId(): int + { + return $this->vehicle_id; + } + + /** + * @param int $vehicle_id * * @return Vehicle */ - public function setId(int $id): Vehicle + public function setVehicleId(int $vehicle_id): Vehicle { - $this->id = $id; + $this->vehicle_id = $vehicle_id; return $this; } @@ -75,39 +130,19 @@ class Vehicle extends Model /** * @return string */ - public function getName(): string + public function getVehicleName(): string { - return $this->name; + return $this->vehicle_name; } /** - * @param string $name + * @param string $vehicle_name * * @return Vehicle */ - public function setName(string $name): Vehicle + public function setVehicleName(string $vehicle_name): Vehicle { - $this->name = $name; - - return $this; - } - - /** - * @return string|null - */ - public function getImagePath(): ?string - { - return $this->image_path; - } - - /** - * @param string|null $image_path - * - * @return Vehicle - */ - public function setImagePath(?string $image_path): Vehicle - { - $this->image_path = $image_path; + $this->vehicle_name = $vehicle_name; return $this; } @@ -115,19 +150,19 @@ class Vehicle extends Model /** * @return int */ - public function getStorage(): int + public function getVehicleStorage(): int { - return $this->storage; + return $this->vehicle_storage; } /** - * @param int $storage + * @param int $vehicle_storage * * @return Vehicle */ - public function setStorage(int $storage): Vehicle + public function setVehicleStorage(int $vehicle_storage): Vehicle { - $this->storage = $storage; + $this->vehicle_storage = $vehicle_storage; return $this; } @@ -135,19 +170,19 @@ class Vehicle extends Model /** * @return int */ - public function getFuelVolume(): int + public function getVehicleFuelVolume(): int { - return $this->fuel_volume; + return $this->vehicle_fuel_volume; } /** - * @param int $fuel_volume + * @param int $vehicle_fuel_volume * * @return Vehicle */ - public function setFuelVolume(int $fuel_volume): Vehicle + public function setVehicleFuelVolume(int $vehicle_fuel_volume): Vehicle { - $this->fuel_volume = $fuel_volume; + $this->vehicle_fuel_volume = $vehicle_fuel_volume; return $this; } @@ -155,19 +190,19 @@ class Vehicle extends Model /** * @return int */ - public function getSeats(): int + public function getVehicleSeats(): int { - return $this->seats; + return $this->vehicle_seats; } /** - * @param int $seats + * @param int $vehicle_seats * * @return Vehicle */ - public function setSeats(int $seats): Vehicle + public function setVehicleSeats(int $vehicle_seats): Vehicle { - $this->seats = $seats; + $this->vehicle_seats = $vehicle_seats; return $this; } @@ -175,19 +210,19 @@ class Vehicle extends Model /** * @return float|null */ - public function getPrice(): ?float + public function getVehiclePrice(): ?float { - return $this->price; + return $this->vehicle_price; } /** - * @param float|null $price + * @param float|null $vehicle_price * * @return Vehicle */ - public function setPrice(?float $price): Vehicle + public function setVehiclePrice(?float $vehicle_price): Vehicle { - $this->price = $price; + $this->vehicle_price = $vehicle_price; return $this; } @@ -195,19 +230,19 @@ class Vehicle extends Model /** * @return float|null */ - public function getTopSpeed(): ?float + public function getVehicleTopSpeed(): ?float { - return $this->top_speed; + return $this->vehicle_top_speed; } /** - * @param float|null $top_speed + * @param float|null $vehicle_top_speed * * @return Vehicle */ - public function setTopSpeed(?float $top_speed): Vehicle + public function setVehicleTopSpeed(?float $vehicle_top_speed): Vehicle { - $this->top_speed = $top_speed; + $this->vehicle_top_speed = $vehicle_top_speed; return $this; } @@ -291,36 +326,4 @@ class Vehicle extends Model return $this; } - - public function scopeFilter( - $query, - array $filters - ): void { - $search = $filters['search'] ?? false; - if ($search) { - $query->where('name', 'like', '%' . $search . '%'); - } - - unset($filters['search']); - - $orderByOne = $filters['orderByOne'] ?? false; - $orderByTwo = $filters['orderByTwo'] ?? false; - if ($orderByOne || $orderByTwo) { - $orderBy = ''; - if ($orderByOne && Schema::hasColumn('vehicles', $orderByOne)) { - $orderBy .= $orderByOne; - } - - if ($orderByTwo && Schema::hasColumn('vehicles', $orderByTwo)) { - $orderBy .= empty($orderBy) ? $orderByTwo : ', ' . $orderByTwo; - } - - $query->orderBy($orderBy); - } - - foreach ($filters as $field => $filter) { - Schema::hasColumn('vehicles', $field); - $query->where($field, '=', $filter); - } - } } diff --git a/app/Models/VehicleClass.php b/app/Models/VehicleClass.php index e085397..48a5a77 100644 --- a/app/Models/VehicleClass.php +++ b/app/Models/VehicleClass.php @@ -12,20 +12,20 @@ use Illuminate\Support\Carbon; /** * App\Models\VehicleClass * - * @property int $id + * @property int $vehicle_class_id * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property string $name - * @property string|null $description - * @method static \Database\Factories\VehicleClassFactory factory($count = null, $state = []) + * @property string $vehicle_class_name + * @property string|null $vehicle_class_description + * @method static VehicleClassFactory factory($count = null, $state = []) * @method static Builder|VehicleClass newModelQuery() * @method static Builder|VehicleClass newQuery() * @method static Builder|VehicleClass query() * @method static Builder|VehicleClass whereCreatedAt($value) - * @method static Builder|VehicleClass whereDescription($value) - * @method static Builder|VehicleClass whereId($value) - * @method static Builder|VehicleClass whereName($value) * @method static Builder|VehicleClass whereUpdatedAt($value) + * @method static Builder|VehicleClass whereVehicleClassDescription($value) + * @method static Builder|VehicleClass whereVehicleClassId($value) + * @method static Builder|VehicleClass whereVehicleClassName($value) * @mixin Eloquent */ class VehicleClass extends Model @@ -35,19 +35,19 @@ class VehicleClass extends Model /** * @return int */ - public function getId(): int + public function getVehicleClassId(): int { - return $this->id; + return $this->vehicle_class_id; } /** - * @param int $id + * @param int $vehicle_class_id * * @return VehicleClass */ - public function setId(int $id): VehicleClass + public function setVehicleClassId(int $vehicle_class_id): VehicleClass { - $this->id = $id; + $this->vehicle_class_id = $vehicle_class_id; return $this; } @@ -55,19 +55,19 @@ class VehicleClass extends Model /** * @return string */ - public function getName(): string + public function getVehicleClassName(): string { - return $this->name; + return $this->vehicle_class_name; } /** - * @param string $name + * @param string $vehicle_class_name * * @return VehicleClass */ - public function setName(string $name): VehicleClass + public function setVehicleClassName(string $vehicle_class_name): VehicleClass { - $this->name = $name; + $this->vehicle_class_name = $vehicle_class_name; return $this; } @@ -75,19 +75,19 @@ class VehicleClass extends Model /** * @return string|null */ - public function getDescription(): ?string + public function getVehicleClassDescription(): ?string { - return $this->description; + return $this->vehicle_class_description; } /** - * @param string|null $description + * @param string|null $vehicle_class_description * * @return VehicleClass */ - public function setDescription(?string $description): VehicleClass + public function setVehicleClassDescription(?string $vehicle_class_description): VehicleClass { - $this->description = $description; + $this->vehicle_class_description = $vehicle_class_description; return $this; } diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 3b93951..61b6c7c 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -12,26 +12,26 @@ use Illuminate\Support\Carbon; /** * App\Models\Vendor * - * @property int $id + * @property int $vendor_id * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property string $name - * @property string|null $description - * @property string|null $position - * @property float|null $x - * @property float|null $y - * @method static \Database\Factories\VendorFactory factory($count = null, $state = []) + * @property string $vendor_name + * @property string|null $vendor_description + * @property string|null $vendor_position + * @property float|null $vendor_x + * @property float|null $vendor_y + * @method static VendorFactory factory($count = null, $state = []) * @method static Builder|Vendor newModelQuery() * @method static Builder|Vendor newQuery() * @method static Builder|Vendor query() * @method static Builder|Vendor whereCreatedAt($value) - * @method static Builder|Vendor whereDescription($value) - * @method static Builder|Vendor whereId($value) - * @method static Builder|Vendor whereName($value) - * @method static Builder|Vendor wherePosition($value) * @method static Builder|Vendor whereUpdatedAt($value) - * @method static Builder|Vendor whereX($value) - * @method static Builder|Vendor whereY($value) + * @method static Builder|Vendor whereVendorDescription($value) + * @method static Builder|Vendor whereVendorId($value) + * @method static Builder|Vendor whereVendorName($value) + * @method static Builder|Vendor whereVendorPosition($value) + * @method static Builder|Vendor whereVendorX($value) + * @method static Builder|Vendor whereVendorY($value) * @mixin Eloquent */ class Vendor extends Model @@ -41,19 +41,19 @@ class Vendor extends Model /** * @return int */ - public function getId(): int + public function getVendorId(): int { - return $this->id; + return $this->vendor_id; } /** - * @param int $id + * @param int $vendor_id * * @return Vendor */ - public function setId(int $id): Vendor + public function setVendorId(int $vendor_id): Vendor { - $this->id = $id; + $this->vendor_id = $vendor_id; return $this; } @@ -61,19 +61,19 @@ class Vendor extends Model /** * @return string */ - public function getName(): string + public function getVendorName(): string { - return $this->name; + return $this->vendor_name; } /** - * @param string $name + * @param string $vendor_name * * @return Vendor */ - public function setName(string $name): Vendor + public function setVendorName(string $vendor_name): Vendor { - $this->name = $name; + $this->vendor_name = $vendor_name; return $this; } @@ -81,19 +81,19 @@ class Vendor extends Model /** * @return string|null */ - public function getDescription(): ?string + public function getVendorDescription(): ?string { - return $this->description; + return $this->vendor_description; } /** - * @param string|null $description + * @param string|null $vendor_description * * @return Vendor */ - public function setDescription(?string $description): Vendor + public function setVendorDescription(?string $vendor_description): Vendor { - $this->description = $description; + $this->vendor_description = $vendor_description; return $this; } @@ -101,19 +101,19 @@ class Vendor extends Model /** * @return string|null */ - public function getPosition(): ?string + public function getVendorPosition(): ?string { - return $this->position; + return $this->vendor_position; } /** - * @param string|null $position + * @param string|null $vendor_position * * @return Vendor */ - public function setPosition(?string $position): Vendor + public function setVendorPosition(?string $vendor_position): Vendor { - $this->position = $position; + $this->vendor_position = $vendor_position; return $this; } @@ -121,19 +121,19 @@ class Vendor extends Model /** * @return float|null */ - public function getX(): ?float + public function getVendorX(): ?float { - return $this->x; + return $this->vendor_x; } /** - * @param float|null $x + * @param float|null $vendor_x * * @return Vendor */ - public function setX(?float $x): Vendor + public function setVendorX(?float $vendor_x): Vendor { - $this->x = $x; + $this->vendor_x = $vendor_x; return $this; } @@ -141,19 +141,19 @@ class Vendor extends Model /** * @return float|null */ - public function getY(): ?float + public function getVendorY(): ?float { - return $this->y; + return $this->vendor_y; } /** - * @param float|null $y + * @param float|null $vendor_y * * @return Vendor */ - public function setY(?float $y): Vendor + public function setVendorY(?float $vendor_y): Vendor { - $this->y = $y; + $this->vendor_y = $vendor_y; return $this; } diff --git a/database/migrations/2023_10_09_212948_make_fields_nullable.php b/database/migrations/2023_10_09_212948_make_fields_nullable.php index 96e2828..c7a829e 100644 --- a/database/migrations/2023_10_09_212948_make_fields_nullable.php +++ b/database/migrations/2023_10_09_212948_make_fields_nullable.php @@ -36,7 +36,6 @@ return new class extends Migration }); Schema::table('vehicles', function (Blueprint $table) { - $table->string('name')->unique()->change(); $table->string('image_path')->nullable(true)->change(); $table->double('price')->nullable(true)->change(); $table->double('top_speed')->nullable(true)->change(); diff --git a/database/migrations/2023_10_09_234833_rename_fields.php b/database/migrations/2023_10_09_234833_rename_fields.php new file mode 100644 index 0000000..3d9fd86 --- /dev/null +++ b/database/migrations/2023_10_09_234833_rename_fields.php @@ -0,0 +1,97 @@ +renameColumn('id', 'vehicle_id'); + $table->renameColumn('name', 'vehicle_name'); + $table->dropColumn('image_path'); + $table->renameColumn('storage', 'vehicle_storage'); + $table->renameColumn('fuel_volume', 'vehicle_fuel_volume'); + $table->renameColumn('seats', 'vehicle_seats'); + $table->renameColumn('price', 'vehicle_price'); + $table->renameColumn('top_speed', 'vehicle_top_speed'); + }); + + Schema::table('vendors', function (Blueprint $table) { + $table->renameColumn('id', 'vendor_id'); + $table->renameColumn('name', 'vendor_name'); + $table->renameColumn('description', 'vendor_description'); + $table->renameColumn('position', 'vendor_position'); + $table->renameColumn('x', 'vendor_x'); + $table->renameColumn('y', 'vendor_y'); + }); + + Schema::table('brands', function (Blueprint $table) { + $table->renameColumn('id', 'brand_id'); + $table->renameColumn('name', 'brand_name'); + $table->renameColumn('description', 'brand_description'); + }); + + Schema::table('vehicle_classes', function (Blueprint $table) { + $table->renameColumn('id', 'vehicle_class_id'); + $table->renameColumn('name', 'vehicle_class_name'); + $table->renameColumn('description', 'vehicle_class_description'); + }); + + Schema::table('fuel_types', function (Blueprint $table) { + $table->renameColumn('id', 'fuel_type_id'); + $table->renameColumn('name', 'fuel_type_name'); + $table->renameColumn('description', 'fuel_type_description'); + $table->renameColumn('price', 'fuel_type_price'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('vehicles', function (Blueprint $table) { + $table->renameColumn('vehicle_id', 'id'); + $table->string('image_path')->nullable(true); + $table->renameColumn('vehicle_storage', 'storage'); + $table->renameColumn('vehicle_fuel_volume', 'fuel_volume'); + $table->renameColumn('vehicle_seats', 'seats'); + $table->renameColumn('vehicle_price', 'price'); + $table->renameColumn('vehicle_top_speed', 'top_speed'); + }); + + Schema::table('vendors', function (Blueprint $table) { + $table->renameColumn('vendor_id', 'id'); + $table->renameColumn('vendor_name', 'name'); + $table->renameColumn('vendor_description', 'description'); + $table->renameColumn('vendor_position', 'position'); + $table->renameColumn('vendor_x', 'x'); + $table->renameColumn('vendor_y', 'y'); + }); + + Schema::table('brands', function (Blueprint $table) { + $table->renameColumn('brand_id', 'id'); + $table->renameColumn('brand_name', 'name'); + $table->renameColumn('brand_description', 'description'); + }); + + Schema::table('vehicle_classes', function (Blueprint $table) { + $table->renameColumn('vehicle_class_id', 'id'); + $table->renameColumn('vehicle_class_name', 'name'); + $table->renameColumn('vehicle_class_description', 'description'); + }); + + Schema::table('fuel_types', function (Blueprint $table) { + $table->renameColumn('fuel_type_id', 'id'); + $table->renameColumn('fuel_type_name', 'name'); + $table->renameColumn('fuel_type_description', 'description'); + $table->renameColumn('fuel_type_price', 'price'); + }); + } +}; diff --git a/public/css/app.css b/public/css/app.css index 6c389c4..410b726 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -13244,6 +13244,15 @@ html{ visibility: visible; opacity: 1; } +.modal-toggle{ + position: fixed; + height: 0px; + width: 0px; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + opacity: 0; +} .select{ display: inline-flex; flex-shrink: 0; @@ -14111,6 +14120,10 @@ html{ margin-left: -0.5rem; margin-right: -0.5rem; } +.mx-2{ + margin-left: 0.5rem; + margin-right: 0.5rem; +} .mx-8{ margin-left: 2rem; margin-right: 2rem; @@ -14288,6 +14301,9 @@ html{ .h-screen{ height: 100vh; } +.h-auto{ + height: auto; +} .max-h-\[20rem\]{ max-height: 20rem; } @@ -14300,6 +14316,12 @@ html{ .max-h-\[90vh\]{ max-height: 90vh; } +.max-h-32{ + max-height: 8rem; +} +.max-h-\[70vh\]{ + max-height: 70vh; +} .min-h-\[15rem\]{ min-height: 15rem; } @@ -14381,6 +14403,9 @@ html{ .min-w-\[20rem\]{ min-width: 20rem; } +.min-w-\[6rem\]{ + min-width: 6rem; +} .min-w-full{ min-width: 100%; } @@ -14406,6 +14431,9 @@ html{ .max-w-\[40rem\]{ max-width: 40rem; } +.max-w-\[8rem\]{ + max-width: 8rem; +} .max-w-md{ max-width: 28rem; } @@ -14416,6 +14444,12 @@ html{ .max-w-xl{ max-width: 36rem; } +.max-w-\[120rem\]{ + max-width: 120rem; +} +.max-w-\[100rem\]{ + max-width: 100rem; +} .flex-1{ flex: 1 1 0%; } @@ -14461,6 +14495,9 @@ html{ .cursor-default{ cursor: default; } +.cursor-pointer{ + cursor: pointer; +} .grid-cols-1{ grid-template-columns: repeat(1, minmax(0, 1fr)); } diff --git a/resources/views/components/image-modal.blade.php b/resources/views/components/image-modal.blade.php new file mode 100644 index 0000000..40dc2a5 --- /dev/null +++ b/resources/views/components/image-modal.blade.php @@ -0,0 +1,5 @@ +@props(['image', 'id']) + + \ No newline at end of file diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index ad9b70a..92b4d90 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -47,7 +47,7 @@
- +

{{ env('APP_NAME') }}

{{ env('APP_TITLE') }}

diff --git a/resources/views/components/layout/sidebar.blade.php b/resources/views/components/layout/sidebar.blade.php index ca13dae..f469464 100644 --- a/resources/views/components/layout/sidebar.blade.php +++ b/resources/views/components/layout/sidebar.blade.php @@ -12,11 +12,13 @@
    - - - - - + @if(env('LANDING_PAGE', false)) + + + + + + @endif diff --git a/resources/views/components/table/row.blade.php b/resources/views/components/table/row.blade.php index 7591556..28ed441 100644 --- a/resources/views/components/table/row.blade.php +++ b/resources/views/components/table/row.blade.php @@ -5,12 +5,12 @@ $type = $args['type']; $value = $args['value'] ?? ($type === 'int' ? 0 : ''); $rowType = 'div'; - $classes = ['p-3 border-opacity-40 border-red-400 grow basis-0 border min-w-[10rem] min-h-[5rem]', ($type === 'int' ? 'text-right' : 'text-left'), ($mode === 'tableVertical' ? 'min-w-[10rem] min-h-[5rem]' : ''), ($header ? 'font-bold' : '')]; + $classes = ['p-3 border-opacity-40 border-red-400 grow basis-0 border min-w-[6rem]', ($type === 'int' ? 'text-right' : 'text-left'), ($mode === 'tableVertical' ? 'max-w-[8rem] min-h-[5rem]' : ''), ($header ? 'font-bold' : '')]; $html = '<' . $rowType . ' class="' . implode(' ', $classes) . '">'; $valueHtml = match ($type) { 'string' => $value, 'int' => $value . ($args['unit'] ?? ''), - 'image' => '' . $field . '' + 'image' => '' }; if (!empty($args['link'])) { @@ -28,5 +28,8 @@
    @foreach($values as $field => $value) {!! getFieldHtml($value, $field, $header, $mode) !!} + @if($value['type'] === 'image') + + @endif @endforeach
    \ No newline at end of file diff --git a/resources/views/components/vehicles/card.blade.php b/resources/views/components/vehicles/card.blade.php index 4a62b2f..5d06f4a 100644 --- a/resources/views/components/vehicles/card.blade.php +++ b/resources/views/components/vehicles/card.blade.php @@ -7,22 +7,23 @@
    - Photo of {{ $vehicle->getName() }} + +
    -

    {{ $vehicle->getName() }}

    +

    {{ $vehicle->getVehicleName() }}

    {{ __('Brand') }}: {{ $brand }} {{ __('Class') }}: {{ $class }} - {{ __('Storage') }}: {{ $vehicle->getStorage() }} + {{ __('Storage') }}: {{ $vehicle->getVehicleStorage() }} {{ __('Fuel Type') }}: {{ $fuelType }} - {{ __('Fuel Volume') }}: {{ $vehicle->getFuelVolume() }} - {{ __('Seats') }}: {{ $vehicle->getSeats() }} - {{ __('Price') }}: {{ $vehicle->getPrice() }} - {{ __('Top Speed') }}: {{ $vehicle->getTopSpeed() }} + {{ __('Fuel Volume') }}: {{ $vehicle->getVehicleFuelVolume() }} + {{ __('Seats') }}: {{ $vehicle->getVehicleSeats() }} + {{ __('Price') }}: {{ $vehicle->getVehiclePrice() }} + {{ __('Top Speed') }}: {{ $vehicle->getVehicleTopSpeed() }}
    diff --git a/resources/views/vehicles/index.blade.php b/resources/views/vehicles/index.blade.php index f09ea6f..8b25634 100644 --- a/resources/views/vehicles/index.blade.php +++ b/resources/views/vehicles/index.blade.php @@ -13,57 +13,73 @@ placeholder="Select Game or AppId" templateResult="true" templateSelection="true" text="item.name + '|AppID: ' + item.appID"> + :enums="$vehicleClasses" functionCall="getVehicleClassName"/> + :enums="$brands" functionCall="getBrandName"/> + :enums="$fuelTypes" functionCall="getFuelTypeName"/> + :enums="$vendors" functionCall="getVendorName"/> @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')], - ]]; + $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; 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()], - ]; + $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]; + } } @endphp - @switch(app('request')->input('listMode')) + @switch(app('request')->input('listMode') ?? env('DEFAULT_DISPLAY_MODE')) @case('tableHorizontal') @case('tableVertical') - + @break @default @foreach($vehicles as $key => $vehicle) - + @endforeach @endswitch diff --git a/routes/web.php b/routes/web.php index d071730..8b3e012 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,6 +16,10 @@ use Illuminate\Support\Facades\Route; */ Route::get('/', static function () { + if (!env('LANDING_PAGE', false)) { + return redirect(route('vehicles')); + } + return view('home'); })->name('home');