From 64b166716e63379025ce30a8b27b065a413771d3 Mon Sep 17 00:00:00 2001 From: Shift Date: Thu, 17 Feb 2022 11:17:35 +0000 Subject: [PATCH 1/3] Shift bindings PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP. --- app/Providers/MorphServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Providers/MorphServiceProvider.php b/app/Providers/MorphServiceProvider.php index e841f91..88077f0 100644 --- a/app/Providers/MorphServiceProvider.php +++ b/app/Providers/MorphServiceProvider.php @@ -14,9 +14,9 @@ class MorphServiceProvider extends ServiceProvider public function boot() { Relation::morphMap([ - 'contracts' => 'App\Models\Contract', - 'cars' => 'App\Models\Car', - 'contacts' => 'App\Models\Contact', + 'contracts' => \App\Models\Contract::class, + 'cars' => \App\Models\Car::class, + 'contacts' => \App\Models\Contact::class, ]); } From 3de473c795c95d40850df86c9115333691190dd0 Mon Sep 17 00:00:00 2001 From: Shift Date: Thu, 17 Feb 2022 11:17:50 +0000 Subject: [PATCH 2/3] Convert `switch` to `match` --- app/Http/Controllers/CarController.php | 72 ++++++++++------------ app/Http/Controllers/ContactController.php | 19 +++--- app/Models/Contract.php | 22 +++---- app/Models/Payment.php | 26 +++----- routes/web.php | 3 +- 5 files changed, 58 insertions(+), 84 deletions(-) diff --git a/app/Http/Controllers/CarController.php b/app/Http/Controllers/CarController.php index 8d0bc60..28a4fab 100644 --- a/app/Http/Controllers/CarController.php +++ b/app/Http/Controllers/CarController.php @@ -224,48 +224,40 @@ class CarController extends Controller private function getWithCustomSort($cars, string $sortBy, string $direction) { - switch($sortBy) { - case 'name': - return $cars - ->leftJoin('car_models', 'cars.car_model_id', '=', 'car_models.id') - ->leftJoin('brands', 'car_models.brand_id', '=', 'brands.id') - ->orderBy('brands.name', $direction) - ->orderBy('car_models.name', $direction); - case 'initial_date': - return $cars->orderBy('initial_date', $direction); - case 'stammnummer': - return $cars->orderBy('stammnummer', $direction); - case 'buy_contract.date': - return $cars - ->leftJoin('contracts', function($join) { - $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); - }) - ->orderBy('contracts.date', $direction); - case 'buy_contract.price': - return $cars - ->leftJoin('contracts', function($join) { - $join->on('contracts.car_id', '=', 'cars.id') + return match ($sortBy) { + 'name' => $cars + ->leftJoin('car_models', 'cars.car_model_id', '=', 'car_models.id') + ->leftJoin('brands', 'car_models.brand_id', '=', 'brands.id') + ->orderBy('brands.name', $direction) + ->orderBy('car_models.name', $direction), + 'initial_date' => $cars->orderBy('initial_date', $direction), + 'stammnummer' => $cars->orderBy('stammnummer', $direction), + 'buy_contract.date' => $cars + ->leftJoin('contracts', function($join) { + $join->on('contracts.car_id', '=', 'cars.id') ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); - }) - ->orderBy('contracts.price', $direction); - case 'sell_contract.date': - return $cars - ->leftJoin('contracts', function($join) { - $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); - }) - ->orderBy('contracts.date', $direction); - case 'sell_contract.price': - return $cars - ->leftJoin('contracts', function($join) { - $join->on('contracts.car_id', '=', 'cars.id') + }) + ->orderBy('contracts.date', $direction), + 'buy_contract.price' => $cars + ->leftJoin('contracts', function($join) { + $join->on('contracts.car_id', '=', 'cars.id') + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); + }) + ->orderBy('contracts.price', $direction), + 'sell_contract.date' => $cars + ->leftJoin('contracts', function($join) { + $join->on('contracts.car_id', '=', 'cars.id') ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); - }) - ->orderBy('contracts.price', $direction); - default: - return $cars->orderBy('initial_date', $direction); - } + }) + ->orderBy('contracts.date', $direction), + 'sell_contract.price' => $cars + ->leftJoin('contracts', function($join) { + $join->on('contracts.car_id', '=', 'cars.id') + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); + }) + ->orderBy('contracts.price', $direction), + default => $cars->orderBy('initial_date', $direction), + }; } private function getSortBy(Request $request, $defaultSort) diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 38093ab..7cefc57 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -130,18 +130,13 @@ class ContactController extends Controller private function getWithCustomSort($contacts, string $sortBy, string $direction) { - switch($sortBy) { - case 'company': - return $contacts->orderBy('company', $direction); - case 'fullCity': - return $contacts->orderBy('city', $direction); - case 'email': - return $contacts->orderBy('email', $direction); - case 'address': - return $contacts->orderBy('address', $direction); - default: - return $contacts->orderByName($direction); - } + return match ($sortBy) { + 'company' => $contacts->orderBy('company', $direction), + 'fullCity' => $contacts->orderBy('city', $direction), + 'email' => $contacts->orderBy('email', $direction), + 'address' => $contacts->orderBy('address', $direction), + default => $contacts->orderByName($direction), + }; } private function getSortBy(Request $request) diff --git a/app/Models/Contract.php b/app/Models/Contract.php index b63dcc0..fcad06e 100644 --- a/app/Models/Contract.php +++ b/app/Models/Contract.php @@ -77,20 +77,14 @@ class Contract extends Model public function getInsuranceTypeFormattedAttribute() { - switch ($this->insurance_type) { - case InsuranceType::QBase: - return 'Q Basis'; - case InsuranceType::OneStar: - return '1 Stern'; - case InsuranceType::ThreeStar: - return '3 Stern'; - case InsuranceType::FiveStar: - return '5 Stern'; - case InsuranceType::FiveStarPlus: - return '5 Stern+'; - default: - return 'Nein'; - } + return match ($this->insurance_type) { + InsuranceType::QBase => 'Q Basis', + InsuranceType::OneStar => '1 Stern', + InsuranceType::ThreeStar => '3 Stern', + InsuranceType::FiveStar => '5 Stern', + InsuranceType::FiveStarPlus => '5 Stern+', + default => 'Nein', + }; } public function getDeletedAtAttribute($deleted_at) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 85b40e7..ab8084c 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -43,26 +43,20 @@ class Payment extends Model public function getTypeAttribute($type) { - switch ($type) { - case PaymentType::Transaction(): - return 'Banküberweisung'; - case PaymentType::Cash(): - return 'Barzahlung'; - default: - return 'Überweisung via Cembra'; - }; + return match ($type) { + PaymentType::Transaction() => 'Banküberweisung', + PaymentType::Cash() => 'Barzahlung', + default => 'Überweisung via Cembra', + };; } public function getTypeTextAttribute() { - switch ($this->type) { - case 'Banküberweisung': - return 'via Banküberweisung erhalten'; - case 'Barzahlung': - return 'in bar erhalten'; - default: - return 'via Cembra-Überweisung erhalten'; - }; + return match ($this->type) { + 'Banküberweisung' => 'via Banküberweisung erhalten', + 'Barzahlung' => 'in bar erhalten', + default => 'via Cembra-Überweisung erhalten', + };; } public function getPrintLinkAttribute() diff --git a/routes/web.php b/routes/web.php index 55099a8..e157056 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,7 +9,6 @@ use App\Http\Controllers\PaymentController; use App\Http\Controllers\ContractController; use App\Http\Controllers\DocumentController; use Illuminate\Support\Facades\Route; - Route::middleware(['auth:sanctum', 'verified'])->group(function () { Route::get('/', [ContractController::class, 'dashboard'])->name('dashboard'); @@ -87,4 +86,4 @@ Route::middleware(['auth:sanctum', 'verified'])->group(function () { Route::post('brands', [BrandController::class, 'store'])->name('brands.store'); Route::post('models', [CarModelController::class, 'store'])->name('models.store'); -}); \ No newline at end of file +}); From 0c344a92efa29bb82b213920fb240c090f03a1aa Mon Sep 17 00:00:00 2001 From: Shift Date: Thu, 17 Feb 2022 11:18:52 +0000 Subject: [PATCH 3/3] Apply laravel code style --- app/Enums/ContractType.php | 1 + app/Enums/InsuranceType.php | 5 + app/Enums/PaymentType.php | 2 + app/Exports/Export.php | 5 +- app/Exports/Report.php | 26 +- app/Http/Controllers/CarController.php | 82 +- app/Http/Controllers/ContactController.php | 45 +- app/Http/Controllers/ContractController.php | 152 +- app/Http/Controllers/Controller.php | 8 +- app/Http/Controllers/DocumentController.php | 15 +- app/Http/Controllers/PaymentController.php | 30 +- app/Http/Controllers/ReportController.php | 11 +- app/Models/Car.php | 26 +- app/Models/Contact.php | 26 +- app/Models/Contract.php | 21 +- app/Models/Document.php | 8 +- app/Models/Payment.php | 11 +- app/Providers/MorphServiceProvider.php | 33 +- app/Providers/RouteServiceProvider.php | 11 +- config/app.php | 2 +- config/money.php | 4 +- database/factories/CarFactory.php | 2 +- database/factories/CarModelFactory.php | 2 +- database/factories/ContactFactory.php | 6 +- database/factories/ContractFactory.php | 10 +- database/factories/DocumentFactory.php | 3 +- database/factories/PaymentFactory.php | 6 +- ...21_05_10_144041_create_contracts_table.php | 4 +- ...021_05_10_144704_create_payments_table.php | 2 +- database/seeders/DatabaseSeeder.php | 2051 ++++++++--------- routes/web.php | 14 +- 31 files changed, 1331 insertions(+), 1293 deletions(-) diff --git a/app/Enums/ContractType.php b/app/Enums/ContractType.php index e5b7247..5d1e40b 100644 --- a/app/Enums/ContractType.php +++ b/app/Enums/ContractType.php @@ -14,5 +14,6 @@ use BenSampo\Enum\Enum; final class ContractType extends Enum { const BuyContract = '0'; + const SellContract = '1'; } diff --git a/app/Enums/InsuranceType.php b/app/Enums/InsuranceType.php index cc39100..f10045b 100644 --- a/app/Enums/InsuranceType.php +++ b/app/Enums/InsuranceType.php @@ -14,9 +14,14 @@ use BenSampo\Enum\Enum; final class InsuranceType extends Enum { const Keine = '0'; + const QBase = '1'; + const OneStar = '2'; + const ThreeStar = '3'; + const FiveStar = '4'; + const FiveStarPlus = '5'; } diff --git a/app/Enums/PaymentType.php b/app/Enums/PaymentType.php index bd43bfb..b29f294 100644 --- a/app/Enums/PaymentType.php +++ b/app/Enums/PaymentType.php @@ -11,6 +11,8 @@ use BenSampo\Enum\Enum; final class PaymentType extends Enum { const Transaction = '0'; + const Cash = '1'; + const Cembra = '2'; } diff --git a/app/Exports/Export.php b/app/Exports/Export.php index f888330..183091e 100644 --- a/app/Exports/Export.php +++ b/app/Exports/Export.php @@ -2,14 +2,15 @@ namespace App\Exports; -use Maatwebsite\Excel\Concerns\WithStyles; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\FromCollection; +use Maatwebsite\Excel\Concerns\WithHeadings; +use Maatwebsite\Excel\Concerns\WithStyles; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class Export implements FromCollection, WithHeadings, WithStyles { protected $model; + protected $headings; public function __construct($model, $headings) diff --git a/app/Exports/Report.php b/app/Exports/Report.php index 4b9b234..c63e6a9 100644 --- a/app/Exports/Report.php +++ b/app/Exports/Report.php @@ -2,21 +2,21 @@ namespace App\Exports; -use Carbon\Carbon; use App\Models\Car; use App\Models\Contract; -use Maatwebsite\Excel\Concerns\WithTitle; -use PhpOffice\PhpSpreadsheet\Style\NumberFormat; -use Maatwebsite\Excel\Concerns\WithColumnFormatting; -use PhpOffice\PhpSpreadsheet\Shared\Date; -use Maatwebsite\Excel\Concerns\WithStyles; -use Maatwebsite\Excel\Concerns\WithMapping; -use Maatwebsite\Excel\Concerns\WithHeadings; +use Carbon\Carbon; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithColumnFormatting; +use Maatwebsite\Excel\Concerns\WithHeadings; +use Maatwebsite\Excel\Concerns\WithMapping; +use Maatwebsite\Excel\Concerns\WithStyles; +use Maatwebsite\Excel\Concerns\WithTitle; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; -class Report implements FromCollection ,WithTitle, WithHeadings, WithStyles, WithColumnFormatting, ShouldAutoSize +class Report implements FromCollection, WithTitle, WithHeadings, WithStyles, WithColumnFormatting, ShouldAutoSize { protected $year; @@ -46,7 +46,7 @@ class Report implements FromCollection ,WithTitle, WithHeadings, WithStyles, Wit $cars = $cars->merge(Car::unsoldOnly()->get())->unique()->map(function ($car) { $bcontract = $car->latestBuyContract(); $scontract = $car->latestSellContract(); - if (!$car->isSold()) { + if (! $car->isSold()) { $scontract = null; } @@ -57,9 +57,9 @@ class Report implements FromCollection ,WithTitle, WithHeadings, WithStyles, Wit 'buy_price' => $bcontract ? $bcontract->price_for_excel : null, 'seller' => $bcontract ? $bcontract->contact->full_title_with_address : null, 'sell_date' => $scontract ? Date::dateTimeToExcel(Carbon::parse($scontract->date)) : null, - 'sell_price' => $scontract ? $scontract->price_for_excel : null, + 'sell_price' => $scontract ? $scontract->price_for_excel : null, 'buyer' => $scontract ? $scontract->contact->full_title_with_address : null, - 'lager' => !$scontract && $bcontract ? $bcontract->price_for_excel : null, + 'lager' => ! $scontract && $bcontract ? $bcontract->price_for_excel : null, ]; })->sortBy('buy_date'); @@ -86,6 +86,6 @@ class Report implements FromCollection ,WithTitle, WithHeadings, WithStyles, Wit public function title(): string { - return 'Wagenhandelbuch ' . $this->year; + return 'Wagenhandelbuch '.$this->year; } } diff --git a/app/Http/Controllers/CarController.php b/app/Http/Controllers/CarController.php index 28a4fab..3f17c3c 100644 --- a/app/Http/Controllers/CarController.php +++ b/app/Http/Controllers/CarController.php @@ -2,16 +2,16 @@ namespace App\Http\Controllers; -use Carbon\Carbon; -use App\Models\Car; -use Inertia\Inertia; -use App\Models\Brand; use App\Exports\Export; +use App\Models\Brand; +use App\Models\Car; use App\Models\Contract; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; -use Maatwebsite\Excel\Facades\Excel; use Illuminate\Support\Facades\Redirect; +use Inertia\Inertia; +use Maatwebsite\Excel\Facades\Excel; class CarController extends Controller { @@ -27,7 +27,6 @@ class CarController extends Controller public function sold(Request $request) { - return $this->renderCarsList($request, Car::soldOnly(), 'Cars/Sold', 'sell_contract.date'); } @@ -60,6 +59,7 @@ class CarController extends Controller ->map(function ($car) { $bcontract = $car->latestBuyContract(); $scontract = $car->latestSellContract(); + return [ 'brand' => $car->brand->name, 'model' => $car->carModel->name, @@ -79,8 +79,8 @@ class CarController extends Controller 'sell_price' => $scontract ? $scontract->price : null, ]; }); - - return Excel::download(new Export($cars, $headings), date('Y-m-d') . '-Alle-Autos.xlsx'); + + return Excel::download(new Export($cars, $headings), date('Y-m-d').'-Alle-Autos.xlsx'); } public function unsoldPrint(Request $request) @@ -108,6 +108,7 @@ class CarController extends Controller ->get() ->map(function ($car) { $contract = $car->latestBuyContract(); + return [ 'brand' => $car->brand->name, 'model' => $car->carModel->name, @@ -124,8 +125,8 @@ class CarController extends Controller 'price' => $contract ? $contract->price : null, ]; }); - - return Excel::download(new Export($cars, $headings), date('Y-m-d') . '-Meine-Autos.xlsx'); + + return Excel::download(new Export($cars, $headings), date('Y-m-d').'-Meine-Autos.xlsx'); } public function soldPrint(Request $request) @@ -157,6 +158,7 @@ class CarController extends Controller ->map(function ($car) { $bcontract = $car->latestBuyContract(); $scontract = $car->latestSellContract(); + return [ 'brand' => $car->brand->name, 'model' => $car->carModel->name, @@ -176,11 +178,12 @@ class CarController extends Controller 'sell_price' => $scontract ? $scontract->price : null, ]; }); - - return Excel::download(new Export($cars, $headings), date('Y-m-d') . '-Verkaufte-Autos.xlsx'); + + return Excel::download(new Export($cars, $headings), date('Y-m-d').'-Verkaufte-Autos.xlsx'); } - private function renderCarsList(Request $request, $cars, string $renderPage, string $defaultSort = 'buy_contract.date') { + private function renderCarsList(Request $request, $cars, string $renderPage, string $defaultSort = 'buy_contract.date') + { $direction = $this->getDirection($request, 'desc'); $sortBy = $this->getSortBy($request, $defaultSort); $cars = $this->getWithCustomSort($cars, $sortBy, $direction); @@ -208,11 +211,13 @@ class CarController extends Controller ]); } - private function getContractFields(?Contract $contract) { - if (!$contract) { + private function getContractFields(?Contract $contract) + { + if (! $contract) { return null; } $contact = $contract->contact; + return [ 'id' => $contract->id, 'date' => $contract->date_formatted, @@ -233,28 +238,29 @@ class CarController extends Controller 'initial_date' => $cars->orderBy('initial_date', $direction), 'stammnummer' => $cars->orderBy('stammnummer', $direction), 'buy_contract.date' => $cars - ->leftJoin('contracts', function($join) { + ->leftJoin('contracts', function ($join) { $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); - }) + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); + }) ->orderBy('contracts.date', $direction), 'buy_contract.price' => $cars - ->leftJoin('contracts', function($join) { + ->leftJoin('contracts', function ($join) { $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); - }) + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '0' order by date desc limit 1)")); + }) ->orderBy('contracts.price', $direction), 'sell_contract.date' => $cars - ->leftJoin('contracts', function($join) { + ->leftJoin('contracts', function ($join) { $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); - }) + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); + }) ->orderBy('contracts.date', $direction), 'sell_contract.price' => $cars - ->leftJoin('contracts', function($join) { + ->leftJoin('contracts', function ($join) { $join->on('contracts.car_id', '=', 'cars.id') - ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); - }) + ->on('contracts.id', '=', DB::raw("(SELECT id from contracts WHERE contracts.car_id = cars.id and type = '1' order by date desc limit 1)")); + } + ) ->orderBy('contracts.price', $direction), default => $cars->orderBy('initial_date', $direction), }; @@ -296,8 +302,9 @@ class CarController extends Controller public function store(Request $request) { $car = $this->createCar($request); - + session()->flash('flash.banner', 'Auto erstellt.'); + return Redirect::route('cars.show', $car); } @@ -308,7 +315,7 @@ class CarController extends Controller ]); $request->validate($this->getValidationRules()); - + if ($request->get('initial_date')) { $request->merge(['initial_date' => Carbon::parse($request->get('initial_date'))->format('Y-m-d')]); } @@ -329,7 +336,7 @@ class CarController extends Controller 'stammnummer' => $car->stammnummer, 'vin' => $car->vin, 'name' => $car->name, - 'label' => $car->name . ' (' . $car->stammnummer . ')', + 'label' => $car->name.' ('.$car->stammnummer.')', 'colour' => $car->colour, 'last_check_date' => $car->last_check_date_formatted, 'kilometers' => $car->kilometers, @@ -384,12 +391,16 @@ class CarController extends Controller ->orderBy('date', 'desc') ->with('contact') ->get() - ->map(function ($contract) { return $this->getContractFields($contract); }), + ->map(function ($contract) { + return $this->getContractFields($contract); + }), 'sell_contracts' => $car->sellContracts() ->orderBy('date', 'desc') ->with('contact') ->get() - ->map(function ($contract) { return $this->getContractFields($contract); }), + ->map(function ($contract) { + return $this->getContractFields($contract); + }), ], ]); } @@ -432,6 +443,7 @@ class CarController extends Controller { $this->updateCar($request, $car); session()->flash('flash.banner', 'Auto geändert.'); + return Redirect::route('cars.show', $car); } @@ -442,8 +454,8 @@ class CarController extends Controller ]); $request->validate([ - 'stammnummer' => ['required', 'unique:cars,stammnummer,' . $car->id . ',id,deleted_at,NULL', 'string', 'size:11', 'regex:/[0-9]{3}[.][0-9]{3}[.][0-9]{3}/i'], - 'vin' => ['required', 'unique:cars,vin,' . $car->id . ',id,deleted_at,NULL', 'string', 'size:17'], + 'stammnummer' => ['required', 'unique:cars,stammnummer,'.$car->id.',id,deleted_at,NULL', 'string', 'size:11', 'regex:/[0-9]{3}[.][0-9]{3}[.][0-9]{3}/i'], + 'vin' => ['required', 'unique:cars,vin,'.$car->id.',id,deleted_at,NULL', 'string', 'size:17'], 'initial_date' => ['required', 'date_format:"d.m.Y"'], 'last_check_date' => ['nullable', 'date_format:"d.m.Y"'], 'colour' => ['nullable', 'max:75'], @@ -468,6 +480,7 @@ class CarController extends Controller { $car->delete(); session()->flash('flash.banner', 'Auto gelöscht.'); + return Redirect::route('cars.show', $car); } @@ -475,6 +488,7 @@ class CarController extends Controller { $car->restore(); session()->flash('flash.banner', 'Auto wiederhergestellt.'); + return Redirect::route('cars.show', $car); } } diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 7cefc57..f768598 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers; -use Inertia\Inertia; use App\Exports\Export; use App\Models\Contact; use App\Models\Contract; use Illuminate\Http\Request; -use Maatwebsite\Excel\Facades\Excel; use Illuminate\Support\Facades\Redirect; +use Inertia\Inertia; +use Maatwebsite\Excel\Facades\Excel; class ContactController extends Controller { @@ -27,7 +27,8 @@ class ContactController extends Controller return $this->renderContactsList($request, Contact::has('sellContracts'), 'Contacts/Buyers'); } - private function renderContactsList(Request $request, $contacts, string $renderPage) { + private function renderContactsList(Request $request, $contacts, string $renderPage) + { $direction = $this->getDirection($request); $sortBy = $this->getSortBy($request); $contacts = $this->getWithCustomSort($contacts, $sortBy, $direction); @@ -56,9 +57,9 @@ class ContactController extends Controller } public function letter(Contact $contact) - { - $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor(resource_path() . '/docx/letter.docx'); - $templateProcessor->setValue('date', date("d.m.Y")); + { + $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor(resource_path().'/docx/letter.docx'); + $templateProcessor->setValue('date', date('d.m.Y')); $templateProcessor->setValue('company', $contact->company); $templateProcessor->setValue('name', $contact->name); $templateProcessor->setValue('address', $contact->address); @@ -66,28 +67,28 @@ class ContactController extends Controller $templateProcessor->setValue('country', $contact->country !== 'CH' ? $contact->country : ''); ob_start(); - $templateProcessor->saveAs("php://output"); + $templateProcessor->saveAs('php://output'); $contents = ob_get_contents(); ob_end_clean(); return response()->streamDownload(function () use ($contents) { echo $contents; - }, 'Briefvorlage ' . $contact->title . '.docx'); + }, 'Briefvorlage '.$contact->title.'.docx'); } public function print(Request $request) { - return $this->printList($request, Contact::query(), date('Y-m-d') . '-Alle-Kontakte.xlsx'); + return $this->printList($request, Contact::query(), date('Y-m-d').'-Alle-Kontakte.xlsx'); } public function buyersPrint(Request $request) { - return $this->printList($request, Contact::has('buyContracts'), date('Y-m-d') . '-Verkäufer.xlsx'); + return $this->printList($request, Contact::has('buyContracts'), date('Y-m-d').'-Verkäufer.xlsx'); } public function sellersPrint(Request $request) { - return $this->printList($request, Contact::has('sellContracts'), date('Y-m-d') . '-Käufer.xlsx'); + return $this->printList($request, Contact::has('sellContracts'), date('Y-m-d').'-Käufer.xlsx'); } private function printList(Request $request, $contacts, $title) @@ -160,6 +161,7 @@ class ContactController extends Controller ); session()->flash('flash.banner', 'Kontakt erstellt.'); + return Redirect::route('contacts.show', $contact); } @@ -202,7 +204,7 @@ class ContactController extends Controller 'city' => $contact->city, 'country' => $contact->country, 'deleted_at' => $contact->deleted_at, - ] + ], ]); } @@ -239,21 +241,27 @@ class ContactController extends Controller ->orderBy('date', 'desc') ->with('car') ->get() - ->map(function ($contract) { return $this->getContractFields($contract); }), + ->map(function ($contract) { + return $this->getContractFields($contract); + }), 'sell_contracts' => $contact->sellContracts() ->orderBy('date', 'desc') ->with('car') ->get() - ->map(function ($contract) { return $this->getContractFields($contract); }), - ] + ->map(function ($contract) { + return $this->getContractFields($contract); + }), + ], ]); } - private function getContractFields(?Contract $contract) { - if (!$contract) { + private function getContractFields(?Contract $contract) + { + if (! $contract) { return null; } $car = $contract->car; + return [ 'id' => $contract->id, 'date' => $contract->date_formatted, @@ -270,6 +278,7 @@ class ContactController extends Controller ); session()->flash('flash.banner', 'Kontakt geändert.'); + return Redirect::route('contacts.show', $contact); } @@ -293,6 +302,7 @@ class ContactController extends Controller { $contact->delete(); session()->flash('flash.banner', 'Kontakt gelöscht.'); + return Redirect::back(); } @@ -300,6 +310,7 @@ class ContactController extends Controller { $contact->restore(); session()->flash('flash.banner', 'Kontakt wiederhergestellt.'); + return Redirect::back(); } } diff --git a/app/Http/Controllers/ContractController.php b/app/Http/Controllers/ContractController.php index efea617..29f1e22 100644 --- a/app/Http/Controllers/ContractController.php +++ b/app/Http/Controllers/ContractController.php @@ -2,24 +2,23 @@ namespace App\Http\Controllers; -use Carbon\Carbon; -use App\Models\Car; -use Inertia\Inertia; -use App\Models\Brand; -use App\Models\Contact; -use App\Models\Payment; -use App\Models\Contract; -use App\Enums\PaymentType; use App\Enums\ContractType; use App\Enums\InsuranceType; -use Illuminate\Http\Request; -use Illuminate\Validation\Rule; +use App\Enums\PaymentType; +use App\Models\Brand; +use App\Models\Car; +use App\Models\Contact; +use App\Models\Contract; +use App\Models\Payment; use Barryvdh\DomPDF\Facade as PDF; +use Carbon\Carbon; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Redirect; +use Illuminate\Validation\Rule; +use Inertia\Inertia; class ContractController extends Controller { - public function dashboard() { return Inertia::render('Dashboard', [ @@ -55,7 +54,7 @@ class ContractController extends Controller public function create(Request $request) { - $type = (string)($request->get('type') ?? '1'); + $type = (string) ($request->get('type') ?? '1'); $car = Car::find($request->get('car')); $contact = Contact::find($request->get('contact')); @@ -80,8 +79,9 @@ class ContractController extends Controller ]); } - private function getCarFields(?Car $car) { - if (!$car) { + private function getCarFields(?Car $car) + { + if (! $car) { return [ 'name' => null, 'label' => null, @@ -93,11 +93,12 @@ class ContractController extends Controller 'initial_date' => null, ]; } + return [ 'name' => $car->name, - 'label' => $car->name . ' (' . $car->stammnummer . ')', + 'label' => $car->name.' ('.$car->stammnummer.')', 'id' => $car->id, - 'stammnummer' => $car->stammnummer, + 'stammnummer' => $car->stammnummer, 'vin' => $car->vin, 'name' => $car->name, 'colour' => $car->colour, @@ -105,8 +106,9 @@ class ContractController extends Controller ]; } - private function getContactFields(?Contact $contact) { - if (!$contact) { + private function getContactFields(?Contact $contact) + { + if (! $contact) { return [ 'id' => null, 'title' => null, @@ -122,6 +124,7 @@ class ContractController extends Controller 'email' => null, ]; } + return [ 'id' => $contact->id, 'title' => $contact->full_title, @@ -141,9 +144,9 @@ class ContractController extends Controller public function store(Request $request) { $request->merge([ - 'type' => (string)$request->get('type'), - 'payment_type' => (string)$request->get('payment_type'), - 'insurance_type' => (string)$request->get('insurance_type'), + 'type' => (string) $request->get('type'), + 'payment_type' => (string) $request->get('payment_type'), + 'insurance_type' => (string) $request->get('insurance_type'), ]); $request->validate([ @@ -165,7 +168,7 @@ class ContractController extends Controller $contract = Contract::create($request->all()); $request->merge([ - 'type' => (string)$request->get('payment_type'), + 'type' => (string) $request->get('payment_type'), 'contract_id' => $contract->id, ]); @@ -181,8 +184,8 @@ class ContractController extends Controller } session()->flash('flash.banner', 'Vertrag erstellt.'); - return Redirect::route('contracts.show', $contract); + return Redirect::route('contracts.show', $contract); } public function edit(Contract $contract) @@ -197,8 +200,8 @@ class ContractController extends Controller 'type' => $contract->type, 'type_formatted' => $contract->type_formatted, 'notes' => $contract->notes, - 'price' => (int)$contract->price->getAmount(), - 'insurance_type' => (string)$contract->insurance_type, + 'price' => (int) $contract->price->getAmount(), + 'insurance_type' => (string) $contract->insurance_type, 'car' => [ 'id' => $contract->car->id, 'name' => $contract->car->name, @@ -211,7 +214,7 @@ class ContractController extends Controller public function update(Request $request, Contract $contract) { $request->merge([ - 'insurance_type' => (string)$request->get('insurance_type'), + 'insurance_type' => (string) $request->get('insurance_type'), ]); $request->validate([ @@ -230,73 +233,75 @@ class ContractController extends Controller $contract->update($request->all()); session()->flash('flash.banner', 'Vertrag geändert.'); + return Redirect::route('contracts.show', $contract); - } public function show(Contract $contract) { - return Inertia::render('Contracts/Show', [ - 'contract' => [ - 'id' => $contract->id, - 'date' => $contract->date_formatted, - 'delivery_date' => $contract->delivery_date_formatted, - 'price' => $contract->price->format(), - 'type' => $contract->type, - 'type_formatted' => $contract->type_formatted, - 'notes' => $contract->notes, - 'paid' => $contract->paid->format(), - 'left_to_pay' => $contract->left_to_pay->format(), - 'left_to_pay_raw' => (int)$contract->left_to_pay->getAmount(), - 'is_sell_contract' => $contract->isSellContract(), - 'documents' => $contract->documents()->orderBy('created_at', 'asc')->get() - ->map(function ($document) { - return [ - 'id' => $document->id, - 'name' => $document->name, - 'size' => $document->size, - 'extension' => $document->extension, - 'link' => $document->link, - 'created_at' => $document->created_at, - ]; - }), - 'payments' => $contract->payments()->orderBy('date', 'asc')->get() - ->map(function ($payment) { - return [ - 'id' => $payment->id, - 'date' => $payment->date, - 'amount' => $payment->amount->format(), - 'type' => $payment->type, - 'print_link' => $payment->print_link, - 'delete_link' => $payment->delete_link, - ]; - }), - 'insurance_type' => $contract->insurance_type ? InsuranceType::fromValue($contract->insurance_type)->key : null, - 'deleted_at' => $contract->deleted_at, - 'contact' => $contract->contact->only(['id', 'full_title', 'link']), - 'car' => $contract->car->only(['id', 'name_with_year', 'link']), - ], - ]); + return Inertia::render('Contracts/Show', [ + 'contract' => [ + 'id' => $contract->id, + 'date' => $contract->date_formatted, + 'delivery_date' => $contract->delivery_date_formatted, + 'price' => $contract->price->format(), + 'type' => $contract->type, + 'type_formatted' => $contract->type_formatted, + 'notes' => $contract->notes, + 'paid' => $contract->paid->format(), + 'left_to_pay' => $contract->left_to_pay->format(), + 'left_to_pay_raw' => (int) $contract->left_to_pay->getAmount(), + 'is_sell_contract' => $contract->isSellContract(), + 'documents' => $contract->documents()->orderBy('created_at', 'asc')->get() + ->map(function ($document) { + return [ + 'id' => $document->id, + 'name' => $document->name, + 'size' => $document->size, + 'extension' => $document->extension, + 'link' => $document->link, + 'created_at' => $document->created_at, + ]; + }), + 'payments' => $contract->payments()->orderBy('date', 'asc')->get() + ->map(function ($payment) { + return [ + 'id' => $payment->id, + 'date' => $payment->date, + 'amount' => $payment->amount->format(), + 'type' => $payment->type, + 'print_link' => $payment->print_link, + 'delete_link' => $payment->delete_link, + ]; + }), + 'insurance_type' => $contract->insurance_type ? InsuranceType::fromValue($contract->insurance_type)->key : null, + 'deleted_at' => $contract->deleted_at, + 'contact' => $contract->contact->only(['id', 'full_title', 'link']), + 'car' => $contract->car->only(['id', 'name_with_year', 'link']), + ], + ]); } public function print(Contract $contract) { $contxt = stream_context_create([ 'ssl' => [ - 'verify_peer' => FALSE, - 'verify_peer_name' => FALSE, - 'allow_self_signed'=> TRUE - ] + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed'=> true, + ], ]); $pdf = PDF::setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true])->loadView('contract', compact('contract')); $pdf->getDomPDF()->setHttpContext($contxt); - return $pdf->stream($contract->date . '_' . $contract->type_formatted . '.pdf'); + + return $pdf->stream($contract->date.'_'.$contract->type_formatted.'.pdf'); } public function destroy(Contract $contract) { $contract->delete(); session()->flash('flash.banner', 'Vertrag gelöscht.'); + return Redirect::route('contracts.show', $contract); } @@ -304,6 +309,7 @@ class ContractController extends Controller { $contract->restore(); session()->flash('flash.banner', 'Vertrag wiederhergestellt.'); + return Redirect::route('contracts.show', $contract); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 3be3531..ee2cc2c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Routing\Controller as BaseController; -use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Foundation\Validation\ValidatesRequests; +use Illuminate\Http\Request; +use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 77874ba..e03c1cc 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -11,7 +11,8 @@ class DocumentController extends Controller public function show(Document $document) { if (file_exists($document->path)) { - header('Content-Disposition: filename="' . $document->name . '"'); + header('Content-Disposition: filename="'.$document->name.'"'); + return response()->file($document->path); } @@ -22,12 +23,12 @@ class DocumentController extends Controller { $class = $request->get('documentable_type'); $id = $request->get('documentable_id'); - if (!in_array($class, ['contracts', 'cars', 'contacts'])) { + if (! in_array($class, ['contracts', 'cars', 'contacts'])) { return []; } $file = $request->file()['document']; - $internalName = date('Y-m-d-H-i-s') . '.' . $file->extension(); + $internalName = date('Y-m-d-H-i-s').'.'.$file->extension(); $document = Document::create([ 'name' => $file->getClientOriginalName(), 'internal_name' => $internalName, @@ -50,10 +51,11 @@ class DocumentController extends Controller public function destroy(Request $request) { - $document = Document::find((int)$request->get('id')); - - if (!$document) { + $document = Document::find((int) $request->get('id')); + + if (! $document) { session()->flash('flash.banner', 'Fehler beim Löschen, Dokument nicht gefunden.'); + return Redirect::back(); } @@ -63,6 +65,7 @@ class DocumentController extends Controller $document->delete(); session()->flash('flash.banner', 'Dokument gelöscht.'); + return Redirect::back(); } } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 3c53a21..48e78a8 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -2,15 +2,15 @@ namespace App\Http\Controllers; -use Carbon\Carbon; -use Inertia\Inertia; -use App\Models\Payment; -use App\Models\Contract; -use Barryvdh\DomPDF\Facade as PDF; use App\Enums\PaymentType; +use App\Models\Contract; +use App\Models\Payment; +use Barryvdh\DomPDF\Facade as PDF; +use Carbon\Carbon; use Illuminate\Http\Request; -use Illuminate\Validation\Rule; use Illuminate\Support\Facades\Redirect; +use Illuminate\Validation\Rule; +use Inertia\Inertia; class PaymentController extends Controller { @@ -22,7 +22,7 @@ class PaymentController extends Controller public function store(Request $request) { $request->merge([ - 'type' => (string)$request->get('type'), + 'type' => (string) $request->get('type'), ]); $request->validate([ @@ -39,6 +39,7 @@ class PaymentController extends Controller $payment = Payment::create($request->all()); session()->flash('flash.banner', 'Einzahlung gespeichert.'); + return Redirect::route('contracts.show', $payment->contract); } @@ -46,24 +47,25 @@ class PaymentController extends Controller { $contxt = stream_context_create([ 'ssl' => [ - 'verify_peer' => FALSE, - 'verify_peer_name' => FALSE, - 'allow_self_signed'=> TRUE - ] + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed'=> true, + ], ]); $pdf = PDF::setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true])->loadView('receipt', compact('contract', 'payment')); $pdf->getDomPDF()->setHttpContext($contxt); - return $pdf->stream($payment->date . '_quittung.pdf'); + + return $pdf->stream($payment->date.'_quittung.pdf'); } public function destroy(Request $request, Contract $contract) { - if (Payment::destroy((int)$request->get('id'))) { + if (Payment::destroy((int) $request->get('id'))) { session()->flash('flash.banner', 'Einzahlung gelöscht.'); } else { session()->flash('flash.banner', 'Fehler beim Löschen, Einzahlung nicht gefunden.'); } - + return Redirect::back(); } } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index d8eb864..9a084da 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -2,21 +2,22 @@ namespace App\Http\Controllers; -use Inertia\Inertia; -use Illuminate\Http\Request; use App\Exports\Report; +use Illuminate\Http\Request; +use Inertia\Inertia; use Maatwebsite\Excel\Facades\Excel as Excel; class ReportController extends Controller { public function index(Request $request) { - return Inertia::render('Reports/Index', ['year' => (int)date('Y'), 'years' => array_reverse(range((int)date('Y') - 20, (int)date('Y')))]); + return Inertia::render('Reports/Index', ['year' => (int) date('Y'), 'years' => array_reverse(range((int) date('Y') - 20, (int) date('Y')))]); } public function print(Request $request) { - $year = (int)$request->get('year'); - return Excel::download(new Report($year), 'Wagenhandelbuch-' . $year .'.xlsx'); + $year = (int) $request->get('year'); + + return Excel::download(new Report($year), 'Wagenhandelbuch-'.$year.'.xlsx'); } } diff --git a/app/Models/Car.php b/app/Models/Car.php index 6f13c3e..8b5518d 100644 --- a/app/Models/Car.php +++ b/app/Models/Car.php @@ -2,11 +2,11 @@ namespace App\Models; -use Carbon\Carbon; use App\Enums\ContractType; +use Carbon\Carbon; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Database\Eloquent\Factories\HasFactory; class Car extends Model { @@ -31,18 +31,18 @@ class Car extends Model public function getNameAttribute() { - if (!$this->carModel) { + if (! $this->carModel) { return ''; } - $out = $this->brand->name . ' ' . $this->carModel->name; + $out = $this->brand->name.' '.$this->carModel->name; return $out; } public function getNameWithYearAttribute() { - return $this->name . ' (' . $this->year . ')'; + return $this->name.' ('.$this->year.')'; } public function getYearAttribute() @@ -74,7 +74,7 @@ class Car extends Model if ($deleted_at) { return Carbon::parse($deleted_at)->format('d.m.Y'); } - + return null; } @@ -127,10 +127,10 @@ class Car extends Model { return $query->withCount([ 'contracts AS buy_contracts_count' => function ($query) { - $query->where('type', (string)ContractType::BuyContract); + $query->where('type', (string) ContractType::BuyContract); }, 'contracts AS sell_contracts_count' => function ($query) { - $query->where('type', (string)ContractType::SellContract); + $query->where('type', (string) ContractType::SellContract); }, ]); } @@ -151,9 +151,9 @@ class Car extends Model $parts = explode(' ', $search); foreach ($parts as $part) { $query->where(function ($query) use ($part) { - $query->orWhere('colour', 'like', $part . '%') - ->orWhere('stammnummer', 'like', $part . '%') - ->orWhere('vin', 'like', $part . '%') + $query->orWhere('colour', 'like', $part.'%') + ->orWhere('stammnummer', 'like', $part.'%') + ->orWhere('vin', 'like', $part.'%') ->orWhereHas('carModel', function ($query) use ($part) { $query->where('name', 'like', $part.'%') ->orWhereHas('brand', function ($query) use ($part) { @@ -169,10 +169,8 @@ class Car extends Model $query->onlyTrashed(); } })->when($filters['brand'] ?? null, function ($query, $brand) { - $query->whereHas('carModel', function($q) use ($brand) - { + $query->whereHas('carModel', function ($q) use ($brand) { $q->where('brand_id', '=', $brand); - })->get(); }); } diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 3d87bb4..d77ef82 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -2,11 +2,11 @@ namespace App\Models; -use Carbon\Carbon; use App\Enums\ContractType; +use Carbon\Carbon; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Database\Eloquent\Factories\HasFactory; class Contact extends Model { @@ -49,7 +49,7 @@ class Contact extends Model if ($deleted_at) { return Carbon::parse($deleted_at)->format('d.m.Y'); } - + return null; } @@ -63,7 +63,6 @@ class Contact extends Model return implode(', ', array_filter([$this->company, $this->name])); } - public function getFullTitleWithAddressAttribute() { return implode(', ', array_filter([$this->full_title, $this->address, $this->full_city])); @@ -71,7 +70,7 @@ class Contact extends Model public function getFullCityAttribute() { - return $this->zip . ' ' . $this->city; + return $this->zip.' '.$this->city; } public function getLinkAttribute() @@ -105,17 +104,16 @@ class Contact extends Model $parts = explode(' ', $search); foreach ($parts as $part) { $query->where(function ($query) use ($part) { - $query->where('firstname', 'like', '%' . $part . '%') - ->orWhere('lastname', 'like', '%' . $part . '%') - ->orWhere('company', 'like', '%' . $part . '%') - ->orWhere('email', 'like', '%' . $part . '%') - ->orWhere('zip', 'like', $part . '%') - ->orWhere('city', 'like', '%' . $part . '%') - ->orWhere('address', 'like', '%' . $part . '%') - ->orWhere('phone', 'like', '%' . $part . '%'); + $query->where('firstname', 'like', '%'.$part.'%') + ->orWhere('lastname', 'like', '%'.$part.'%') + ->orWhere('company', 'like', '%'.$part.'%') + ->orWhere('email', 'like', '%'.$part.'%') + ->orWhere('zip', 'like', $part.'%') + ->orWhere('city', 'like', '%'.$part.'%') + ->orWhere('address', 'like', '%'.$part.'%') + ->orWhere('phone', 'like', '%'.$part.'%'); }); } - })->when($filters['trashed'] ?? null, function ($query, $trashed) { if ($trashed === 'with') { $query->withTrashed(); diff --git a/app/Models/Contract.php b/app/Models/Contract.php index fcad06e..0d5908b 100644 --- a/app/Models/Contract.php +++ b/app/Models/Contract.php @@ -2,13 +2,13 @@ namespace App\Models; -use Carbon\Carbon; -use Cknow\Money\Money; use App\Enums\ContractType; use App\Enums\InsuranceType; +use Carbon\Carbon; +use Cknow\Money\Money; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Database\Eloquent\Factories\HasFactory; class Contract extends Model { @@ -47,31 +47,26 @@ class Contract extends Model public function getPaidAttribute() { - return Money::CHF($this->payments()->sum('amount')); } public function getPaidInCashAttribute() { - return Money::CHF($this->payments()->cashOnly()->sum('amount')); } public function getPaidInTransactionAttribute() { - return Money::CHF($this->payments()->transactionOnly()->sum('amount')); } public function getPaidInCembraAttribute() { - return Money::CHF($this->payments()->cembraOnly()->sum('amount')); } public function getLeftToPayAttribute() { - return $this->price->subtract($this->paid); } @@ -92,18 +87,18 @@ class Contract extends Model if ($deleted_at) { return Carbon::parse($deleted_at)->format('d.m.Y'); } - + return null; } public function isBuyContract() { - return $this->type === (string)ContractType::BuyContract; + return $this->type === (string) ContractType::BuyContract; } public function isSellContract() { - return $this->type === (string)ContractType::SellContract; + return $this->type === (string) ContractType::SellContract; } public function getTypeFormattedAttribute() @@ -158,11 +153,11 @@ class Contract extends Model public function scopeBuyContracts($query) { - $query->where('type', (string)ContractType::BuyContract); + $query->where('type', (string) ContractType::BuyContract); } public function scopeSellContracts($query) { - $query->where('type', (string)ContractType::SellContract); + $query->where('type', (string) ContractType::SellContract); } } diff --git a/app/Models/Document.php b/app/Models/Document.php index 353de1b..cfd4662 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -3,8 +3,8 @@ namespace App\Models; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; class Document extends Model { @@ -37,14 +37,14 @@ class Document extends Model public function getSizeAttribute($size) { if ($size / 1024 < 1) { - return $size . " B"; + return $size.' B'; } if ($size / 1024 / 1024 < 1) { - return floor($size / 1024) . " KB"; + return floor($size / 1024).' KB'; } - return floor($size / 1024 / 1024) . " MB"; + return floor($size / 1024 / 1024).' MB'; } public function getLinkAttribute() diff --git a/app/Models/Payment.php b/app/Models/Payment.php index ab8084c..0a7dea2 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -2,12 +2,12 @@ namespace App\Models; +use App\Enums\PaymentType; +use App\Models\Contract; use Carbon\Carbon; use Cknow\Money\Money; -use App\Models\Contract; -use App\Enums\PaymentType; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; class Payment extends Model { @@ -42,12 +42,11 @@ class Payment extends Model public function getTypeAttribute($type) { - return match ($type) { PaymentType::Transaction() => 'Banküberweisung', PaymentType::Cash() => 'Barzahlung', default => 'Überweisung via Cembra', - };; + }; } public function getTypeTextAttribute() @@ -56,7 +55,7 @@ class Payment extends Model 'Banküberweisung' => 'via Banküberweisung erhalten', 'Barzahlung' => 'in bar erhalten', default => 'via Cembra-Überweisung erhalten', - };; + }; } public function getPrintLinkAttribute() diff --git a/app/Providers/MorphServiceProvider.php b/app/Providers/MorphServiceProvider.php index 88077f0..ab987df 100644 --- a/app/Providers/MorphServiceProvider.php +++ b/app/Providers/MorphServiceProvider.php @@ -1,32 +1,33 @@ \App\Models\Contract::class, - 'cars' => \App\Models\Car::class, - 'contacts' => \App\Models\Contact::class, - ]); - } + /** + * Bootstrap services. + * + * @return void + */ + public function boot() + { + Relation::morphMap([ + 'contracts' => \App\Models\Contract::class, + 'cars' => \App\Models\Car::class, + 'contacts' => \App\Models\Contact::class, + ]); + } /** * Register services. * * @return void */ - public function register() + public function register() { - // + // } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index d8c65bc..ccea2e7 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -4,13 +4,13 @@ namespace App\Providers; use App\Models\Car; use App\Models\Contact; -use App\Models\Payment; use App\Models\Contract; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Route; +use App\Models\Payment; use Illuminate\Cache\RateLimiting\Limit; -use Illuminate\Support\Facades\RateLimiter; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\RateLimiter; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { @@ -46,6 +46,7 @@ class RouteServiceProvider extends ServiceProvider if (in_array(Route::currentRouteName(), ['cars.show', 'cars.restore'])) { return Car::withTrashed()->find($value); } + return Car::find($value); }); @@ -53,6 +54,7 @@ class RouteServiceProvider extends ServiceProvider if (in_array(Route::currentRouteName(), ['contacts.show', 'contacts.restore'])) { return Contact::withTrashed()->find($value); } + return Contact::find($value); }); @@ -60,6 +62,7 @@ class RouteServiceProvider extends ServiceProvider if (in_array(Route::currentRouteName(), ['contracts.show', 'contracts.restore', 'payments.destroy', 'payments.print'])) { return Contract::withTrashed()->find($value); } + return Contract::find($value); }); diff --git a/config/app.php b/config/app.php index 96b6c5f..1b45cb0 100644 --- a/config/app.php +++ b/config/app.php @@ -230,7 +230,7 @@ return [ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, - 'PDF' => Barryvdh\DomPDF\Facade::class, + 'PDF' => Barryvdh\DomPDF\Facade::class, ], ]; diff --git a/config/money.php b/config/money.php index 3f147c4..cbbd6ee 100644 --- a/config/money.php +++ b/config/money.php @@ -14,6 +14,6 @@ return [ 'custom' => [ // 'MY1' => 2, // 'MY2' => 3 - ] - ] + ], + ], ]; diff --git a/database/factories/CarFactory.php b/database/factories/CarFactory.php index b849007..77a909b 100644 --- a/database/factories/CarFactory.php +++ b/database/factories/CarFactory.php @@ -23,7 +23,7 @@ class CarFactory extends Factory public function definition() { return [ - 'stammnummer' => $this->faker->randomNumber(3, true) . '.' . $this->faker->randomNumber(3, true) . '.' . $this->faker->randomNumber(3, true), + 'stammnummer' => $this->faker->randomNumber(3, true).'.'.$this->faker->randomNumber(3, true).'.'.$this->faker->randomNumber(3, true), 'vin' => $this->faker->regexify('[A-Z]{3}ZZZ[A-Z0-9]{3}[A-Z1-9]{1}[A-Z]{1}[0-9]{6}'), 'colour' => $this->faker->safeColorName(), 'notes' => $this->faker->paragraph(), diff --git a/database/factories/CarModelFactory.php b/database/factories/CarModelFactory.php index 3fb0782..fdb0ba6 100644 --- a/database/factories/CarModelFactory.php +++ b/database/factories/CarModelFactory.php @@ -2,9 +2,9 @@ namespace Database\Factories; +use App\Models\Brand; use App\Models\CarModel; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Brand; class CarModelFactory extends Factory { diff --git a/database/factories/ContactFactory.php b/database/factories/ContactFactory.php index 235cd60..5b3cbf8 100644 --- a/database/factories/ContactFactory.php +++ b/database/factories/ContactFactory.php @@ -3,11 +3,11 @@ namespace Database\Factories; use App\Models\Contact; -use Illuminate\Database\Eloquent\Factories\Factory; use Faker\Provider\de_CH\PhoneNumber; -use Faker\Provider\en_US\Person; use Faker\Provider\en_US\Address; use Faker\Provider\en_US\Company; +use Faker\Provider\en_US\Person; +use Illuminate\Database\Eloquent\Factories\Factory; class ContactFactory extends Factory { @@ -30,7 +30,7 @@ class ContactFactory extends Factory 'lastname' => $this->faker->lastName(), 'phone' => $this->faker->PhoneNumber(), 'email' => $this->faker->email(), - 'address' => $this->faker->streetName() . ' ' . $this->faker->buildingNumber(), + 'address' => $this->faker->streetName().' '.$this->faker->buildingNumber(), 'zip' => $this->faker->randomNumber(4, true), 'city' => $this->faker->city(), 'country' => 'CH', diff --git a/database/factories/ContractFactory.php b/database/factories/ContractFactory.php index 8930219..3aaaf04 100644 --- a/database/factories/ContractFactory.php +++ b/database/factories/ContractFactory.php @@ -2,12 +2,12 @@ namespace Database\Factories; -use App\Models\Contract; +use App\Enums\ContractType; +use App\Enums\InsuranceType; use App\Models\Car; use App\Models\Contact; +use App\Models\Contract; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Enums\InsuranceType; -use App\Enums\ContractType; class ContractFactory extends Factory { @@ -32,8 +32,8 @@ class ContractFactory extends Factory 'price' => $this->faker->numberBetween(150000, 3500000), 'contact_id' => $this->faker->numberBetween(1, Contact::count()), 'car_id' => $this->faker->numberBetween(1, Car::count()), - 'insurance_type' => (string)InsuranceType::getRandomValue(), - 'type' => (string)ContractType::getRandomValue(), + 'insurance_type' => (string) InsuranceType::getRandomValue(), + 'type' => (string) ContractType::getRandomValue(), ]; } } diff --git a/database/factories/DocumentFactory.php b/database/factories/DocumentFactory.php index e2ed364..60487b2 100644 --- a/database/factories/DocumentFactory.php +++ b/database/factories/DocumentFactory.php @@ -2,11 +2,10 @@ namespace Database\Factories; -use App\Models\Document; use App\Models\Contract; +use App\Models\Document; use Illuminate\Database\Eloquent\Factories\Factory; - class DocumentFactory extends Factory { /** diff --git a/database/factories/PaymentFactory.php b/database/factories/PaymentFactory.php index 8280074..71f4886 100644 --- a/database/factories/PaymentFactory.php +++ b/database/factories/PaymentFactory.php @@ -2,10 +2,10 @@ namespace Database\Factories; -use App\Models\Payment; -use Illuminate\Database\Eloquent\Factories\Factory; use App\Enums\PaymentType; use App\Models\Contract; +use App\Models\Payment; +use Illuminate\Database\Eloquent\Factories\Factory; class PaymentFactory extends Factory { @@ -26,7 +26,7 @@ class PaymentFactory extends Factory return [ 'amount' => $this->faker->numberBetween(1000, 10000), 'date' => $this->faker->date(), - 'type' => (string)PaymentType::getRandomValue(), + 'type' => (string) PaymentType::getRandomValue(), 'contract_id' => $this->faker->numberBetween(1, Contract::count()), ]; } diff --git a/database/migrations/2021_05_10_144041_create_contracts_table.php b/database/migrations/2021_05_10_144041_create_contracts_table.php index 42c7ecc..e258bc1 100644 --- a/database/migrations/2021_05_10_144041_create_contracts_table.php +++ b/database/migrations/2021_05_10_144041_create_contracts_table.php @@ -1,10 +1,10 @@ create([ - 'name' => 'Mohamad Salloum', - 'email' => env('USER_2_EMAIL'), - 'password' => bcrypt(env('USER_2_PW')), + 'name' => 'Mohamad Salloum', + 'email' => env('USER_2_EMAIL'), + 'password' => bcrypt(env('USER_2_PW')), ]); User::factory()->create([ - 'name' => 'Nadim Salloum', - 'email' => env('USER_3_EMAIL'), - 'password' => bcrypt(env('USER_3_PW')), + 'name' => 'Nadim Salloum', + 'email' => env('USER_3_EMAIL'), + 'password' => bcrypt(env('USER_3_PW')), ]); foreach ($this->getBrands() as $brandItem) { $brand = Brand::create(['name' => $brandItem['brand']]); - - foreach($brandItem['models'] as $model) { + + foreach ($brandItem['models'] as $model) { CarModel::create([ 'name' => $model, 'brand_id' => $brand->id, ]); } } - + $contacts = Contact::factory() ->count(60) ->create(); @@ -85,1093 +85,1092 @@ class DatabaseSeeder extends Seeder { return [ 0 => [ - 'brand' => 'Seat', - 'models' => [ - 0 => 'Alhambra', - 1 => 'Altea', - 2 => 'Altea XL', - 3 => 'Arosa', - 4 => 'Cordoba', - 5 => 'Cordoba Vario', - 6 => 'Exeo', - 7 => 'Ibiza', - 8 => 'Ibiza ST', - 9 => 'Exeo ST', - 10 => 'Leon', - 11 => 'Leon ST', - 12 => 'Inca', - 13 => 'Mii', - 14 => 'Toledo', - ], + 'brand' => 'Seat', + 'models' => [ + 0 => 'Alhambra', + 1 => 'Altea', + 2 => 'Altea XL', + 3 => 'Arosa', + 4 => 'Cordoba', + 5 => 'Cordoba Vario', + 6 => 'Exeo', + 7 => 'Ibiza', + 8 => 'Ibiza ST', + 9 => 'Exeo ST', + 10 => 'Leon', + 11 => 'Leon ST', + 12 => 'Inca', + 13 => 'Mii', + 14 => 'Toledo', + ], ], 1 => [ - 'brand' => 'Renault', - 'models' => [ - 0 => 'Captur', - 1 => 'Clio', - 2 => 'Clio Grandtour', - 3 => 'Espace', - 4 => 'Express', - 5 => 'Fluence', - 6 => 'Grand Espace', - 7 => 'Grand Modus', - 8 => 'Grand Scenic', - 9 => 'Kadjar', - 10 => 'Kangoo', - 11 => 'Kangoo Express', - 12 => 'Koleos', - 13 => 'Laguna', - 14 => 'Laguna Grandtour', - 15 => 'Latitude', - 16 => 'Mascott', - 17 => 'Mégane', - 18 => 'Mégane CC', - 19 => 'Mégane Combi', - 20 => 'Mégane Grandtour', - 21 => 'Mégane Coupé', - 22 => 'Mégane Scénic', - 23 => 'Scénic', - 24 => 'Talisman', - 25 => 'Talisman Grandtour', - 26 => 'Thalia', - 27 => 'Twingo', - 28 => 'Wind', - 29 => 'Zoé', - ], + 'brand' => 'Renault', + 'models' => [ + 0 => 'Captur', + 1 => 'Clio', + 2 => 'Clio Grandtour', + 3 => 'Espace', + 4 => 'Express', + 5 => 'Fluence', + 6 => 'Grand Espace', + 7 => 'Grand Modus', + 8 => 'Grand Scenic', + 9 => 'Kadjar', + 10 => 'Kangoo', + 11 => 'Kangoo Express', + 12 => 'Koleos', + 13 => 'Laguna', + 14 => 'Laguna Grandtour', + 15 => 'Latitude', + 16 => 'Mascott', + 17 => 'Mégane', + 18 => 'Mégane CC', + 19 => 'Mégane Combi', + 20 => 'Mégane Grandtour', + 21 => 'Mégane Coupé', + 22 => 'Mégane Scénic', + 23 => 'Scénic', + 24 => 'Talisman', + 25 => 'Talisman Grandtour', + 26 => 'Thalia', + 27 => 'Twingo', + 28 => 'Wind', + 29 => 'Zoé', + ], ], 2 => [ - 'brand' => 'Peugeot', - 'models' => [ - 0 => '1007', - 1 => '107', - 2 => '106', - 3 => '108', - 4 => '2008', - 5 => '205', - 6 => '205 Cabrio', - 7 => '206', - 8 => '206 CC', - 9 => '206 SW', - 10 => '207', - 11 => '207 CC', - 12 => '207 SW', - 13 => '306', - 14 => '307', - 15 => '307 CC', - 16 => '307 SW', - 17 => '308', - 18 => '308 CC', - 19 => '308 SW', - 20 => '309', - 21 => '4007', - 22 => '4008', - 23 => '405', - 24 => '406', - 25 => '407', - 26 => '407 SW', - 27 => '5008', - 28 => '508', - 29 => '508 SW', - 30 => '605', - 31 => '806', - 32 => '607', - 33 => '807', - 34 => 'Bipper', - 35 => 'RCZ', - ], + 'brand' => 'Peugeot', + 'models' => [ + 0 => '1007', + 1 => '107', + 2 => '106', + 3 => '108', + 4 => '2008', + 5 => '205', + 6 => '205 Cabrio', + 7 => '206', + 8 => '206 CC', + 9 => '206 SW', + 10 => '207', + 11 => '207 CC', + 12 => '207 SW', + 13 => '306', + 14 => '307', + 15 => '307 CC', + 16 => '307 SW', + 17 => '308', + 18 => '308 CC', + 19 => '308 SW', + 20 => '309', + 21 => '4007', + 22 => '4008', + 23 => '405', + 24 => '406', + 25 => '407', + 26 => '407 SW', + 27 => '5008', + 28 => '508', + 29 => '508 SW', + 30 => '605', + 31 => '806', + 32 => '607', + 33 => '807', + 34 => 'Bipper', + 35 => 'RCZ', + ], ], 3 => [ - 'brand' => 'Dacia', - 'models' => [ - 0 => 'Dokker', - 1 => 'Duster', - 2 => 'Lodgy', - 3 => 'Logan', - 4 => 'Logan MCV', - 5 => 'Logan Van', - 6 => 'Sandero', - 7 => 'Solenza', - ], + 'brand' => 'Dacia', + 'models' => [ + 0 => 'Dokker', + 1 => 'Duster', + 2 => 'Lodgy', + 3 => 'Logan', + 4 => 'Logan MCV', + 5 => 'Logan Van', + 6 => 'Sandero', + 7 => 'Solenza', + ], ], 4 => [ - 'brand' => 'Citroën', - 'models' => [ - 0 => 'Berlingo', - 1 => 'C-Crosser', - 2 => 'C-Elissée', - 3 => 'C-Zero', - 4 => 'C1', - 5 => 'C2', - 6 => 'C3', - 7 => 'C3 Picasso', - 8 => 'C4', - 9 => 'C4 Aircross', - 10 => 'C4 Cactus', - 11 => 'C4 Coupé', - 12 => 'C4 Grand Picasso', - 13 => 'C4 Sedan', - 14 => 'C5', - 15 => 'C5 Break', - 16 => 'C5 Tourer', - 17 => 'C6', - 18 => 'C8', - 19 => 'DS3', - 20 => 'DS4', - 21 => 'DS5', - 22 => 'Evasion', - 23 => 'Jumper', - 24 => 'Jumpy', - 25 => 'Saxo', - 26 => 'Nemo', - 27 => 'Xantia', - 28 => 'Xsara', - ], + 'brand' => 'Citroën', + 'models' => [ + 0 => 'Berlingo', + 1 => 'C-Crosser', + 2 => 'C-Elissée', + 3 => 'C-Zero', + 4 => 'C1', + 5 => 'C2', + 6 => 'C3', + 7 => 'C3 Picasso', + 8 => 'C4', + 9 => 'C4 Aircross', + 10 => 'C4 Cactus', + 11 => 'C4 Coupé', + 12 => 'C4 Grand Picasso', + 13 => 'C4 Sedan', + 14 => 'C5', + 15 => 'C5 Break', + 16 => 'C5 Tourer', + 17 => 'C6', + 18 => 'C8', + 19 => 'DS3', + 20 => 'DS4', + 21 => 'DS5', + 22 => 'Evasion', + 23 => 'Jumper', + 24 => 'Jumpy', + 25 => 'Saxo', + 26 => 'Nemo', + 27 => 'Xantia', + 28 => 'Xsara', + ], ], 5 => [ - 'brand' => 'Opel', - 'models' => [ - 0 => 'Agila', - 1 => 'Ampera', - 2 => 'Antara', - 3 => 'Astra', - 4 => 'Astra cabrio', - 5 => 'Astra caravan', - 6 => 'Astra coupé', - 7 => 'Calibra', - 8 => 'Campo', - 9 => 'Cascada', - 10 => 'Corsa', - 11 => 'Frontera', - 12 => 'Insignia', - 13 => 'Insignia kombi', - 14 => 'Kadett', - 15 => 'Meriva', - 16 => 'Mokka', - 17 => 'Movano', - 18 => 'Omega', - 19 => 'Signum', - 20 => 'Vectra', - 21 => 'Vectra Caravan', - 22 => 'Vivaro', - 23 => 'Vivaro Kombi', - 24 => 'Zafira', - ], + 'brand' => 'Opel', + 'models' => [ + 0 => 'Agila', + 1 => 'Ampera', + 2 => 'Antara', + 3 => 'Astra', + 4 => 'Astra cabrio', + 5 => 'Astra caravan', + 6 => 'Astra coupé', + 7 => 'Calibra', + 8 => 'Campo', + 9 => 'Cascada', + 10 => 'Corsa', + 11 => 'Frontera', + 12 => 'Insignia', + 13 => 'Insignia kombi', + 14 => 'Kadett', + 15 => 'Meriva', + 16 => 'Mokka', + 17 => 'Movano', + 18 => 'Omega', + 19 => 'Signum', + 20 => 'Vectra', + 21 => 'Vectra Caravan', + 22 => 'Vivaro', + 23 => 'Vivaro Kombi', + 24 => 'Zafira', + ], ], 6 => [ - 'brand' => 'Alfa Romeo', - 'models' => [ - 0 => '145', - 1 => '146', - 2 => '147', - 3 => '155', - 4 => '156', - 5 => '156 Sportwagon', - 6 => '159', - 7 => '159 Sportwagon', - 8 => '164', - 9 => '166', - 10 => '4C', - 11 => 'Brera', - 12 => 'GTV', - 13 => 'MiTo', - 14 => 'Crosswagon', - 15 => 'Spider', - 16 => 'GT', - 17 => 'Giulietta', - 18 => 'Giulia', - ], + 'brand' => 'Alfa Romeo', + 'models' => [ + 0 => '145', + 1 => '146', + 2 => '147', + 3 => '155', + 4 => '156', + 5 => '156 Sportwagon', + 6 => '159', + 7 => '159 Sportwagon', + 8 => '164', + 9 => '166', + 10 => '4C', + 11 => 'Brera', + 12 => 'GTV', + 13 => 'MiTo', + 14 => 'Crosswagon', + 15 => 'Spider', + 16 => 'GT', + 17 => 'Giulietta', + 18 => 'Giulia', + ], ], 7 => [ - 'brand' => 'Skoda', - 'models' => [ - 0 => 'Favorit', - 1 => 'Felicia', - 2 => 'Citigo', - 3 => 'Fabia', - 4 => 'Fabia Combi', - 5 => 'Fabia Sedan', - 6 => 'Felicia Combi', - 7 => 'Octavia', - 8 => 'Octavia Combi', - 9 => 'Roomster', - 10 => 'Yeti', - 11 => 'Rapid', - 12 => 'Rapid Spaceback', - 13 => 'Superb', - 14 => 'Superb Combi', - ], + 'brand' => 'Skoda', + 'models' => [ + 0 => 'Favorit', + 1 => 'Felicia', + 2 => 'Citigo', + 3 => 'Fabia', + 4 => 'Fabia Combi', + 5 => 'Fabia Sedan', + 6 => 'Felicia Combi', + 7 => 'Octavia', + 8 => 'Octavia Combi', + 9 => 'Roomster', + 10 => 'Yeti', + 11 => 'Rapid', + 12 => 'Rapid Spaceback', + 13 => 'Superb', + 14 => 'Superb Combi', + ], ], 8 => [ - 'brand' => 'Chevrolet', - 'models' => [ - 0 => 'Alero', - 1 => 'Aveo', - 2 => 'Camaro', - 3 => 'Captiva', - 4 => 'Corvette', - 5 => 'Cruze', - 6 => 'Cruze SW', - 7 => 'Epica', - 8 => 'Equinox', - 9 => 'Evanda', - 10 => 'HHR', - 11 => 'Kalos', - 12 => 'Lacetti', - 13 => 'Lacetti SW', - 14 => 'Lumina', - 15 => 'Malibu', - 16 => 'Matiz', - 17 => 'Monte Carlo', - 18 => 'Nubira', - 19 => 'Orlando', - 20 => 'Spark', - 21 => 'Suburban', - 22 => 'Tacuma', - 23 => 'Tahoe', - 24 => 'Trax', - ], + 'brand' => 'Chevrolet', + 'models' => [ + 0 => 'Alero', + 1 => 'Aveo', + 2 => 'Camaro', + 3 => 'Captiva', + 4 => 'Corvette', + 5 => 'Cruze', + 6 => 'Cruze SW', + 7 => 'Epica', + 8 => 'Equinox', + 9 => 'Evanda', + 10 => 'HHR', + 11 => 'Kalos', + 12 => 'Lacetti', + 13 => 'Lacetti SW', + 14 => 'Lumina', + 15 => 'Malibu', + 16 => 'Matiz', + 17 => 'Monte Carlo', + 18 => 'Nubira', + 19 => 'Orlando', + 20 => 'Spark', + 21 => 'Suburban', + 22 => 'Tacuma', + 23 => 'Tahoe', + 24 => 'Trax', + ], ], 9 => [ - 'brand' => 'Porsche', - 'models' => [ - 0 => '911 Carrera', - 1 => '911 Carrera Cabrio', - 2 => '911 Targa', - 3 => '911 Turbo', - 4 => '924', - 5 => '944', - 6 => '997', - 7 => 'Boxster', - 8 => 'Cayenne', - 9 => 'Cayman', - 10 => 'Macan', - 11 => 'Panamera', - ], + 'brand' => 'Porsche', + 'models' => [ + 0 => '911 Carrera', + 1 => '911 Carrera Cabrio', + 2 => '911 Targa', + 3 => '911 Turbo', + 4 => '924', + 5 => '944', + 6 => '997', + 7 => 'Boxster', + 8 => 'Cayenne', + 9 => 'Cayman', + 10 => 'Macan', + 11 => 'Panamera', + ], ], 10 => [ - 'brand' => 'Honda', - 'models' => [ - 0 => 'Accord', - 1 => 'Accord Coupé', - 2 => 'Accord Tourer', - 3 => 'City', - 4 => 'Civic', - 5 => 'Civic Aerodeck', - 6 => 'Civic Coupé', - 7 => 'Civic Tourer', - 8 => 'Civic Type R', - 9 => 'CR-V', - 10 => 'CR-X', - 11 => 'CR-Z', - 12 => 'FR-V', - 13 => 'HR-V', - 14 => 'Insight', - 15 => 'Integra', - 16 => 'Jazz', - 17 => 'Legend', - 18 => 'Prelude', - ], + 'brand' => 'Honda', + 'models' => [ + 0 => 'Accord', + 1 => 'Accord Coupé', + 2 => 'Accord Tourer', + 3 => 'City', + 4 => 'Civic', + 5 => 'Civic Aerodeck', + 6 => 'Civic Coupé', + 7 => 'Civic Tourer', + 8 => 'Civic Type R', + 9 => 'CR-V', + 10 => 'CR-X', + 11 => 'CR-Z', + 12 => 'FR-V', + 13 => 'HR-V', + 14 => 'Insight', + 15 => 'Integra', + 16 => 'Jazz', + 17 => 'Legend', + 18 => 'Prelude', + ], ], 11 => [ - 'brand' => 'Subaru', - 'models' => [ - 0 => 'BRZ', - 1 => 'Forester', - 2 => 'Impreza', - 3 => 'Impreza Wagon', - 4 => 'Justy', - 5 => 'Legacy', - 6 => 'Legacy Wagon', - 7 => 'Legacy Outback', - 8 => 'Levorg', - 9 => 'Outback', - 10 => 'SVX', - 11 => 'Tribeca', - 12 => 'Tribeca B9', - 13 => 'XV', - ], + 'brand' => 'Subaru', + 'models' => [ + 0 => 'BRZ', + 1 => 'Forester', + 2 => 'Impreza', + 3 => 'Impreza Wagon', + 4 => 'Justy', + 5 => 'Legacy', + 6 => 'Legacy Wagon', + 7 => 'Legacy Outback', + 8 => 'Levorg', + 9 => 'Outback', + 10 => 'SVX', + 11 => 'Tribeca', + 12 => 'Tribeca B9', + 13 => 'XV', + ], ], 12 => [ - 'brand' => 'Mazda', - 'models' => [ - 0 => '121', - 1 => '2', - 2 => '3', - 3 => '323', - 4 => '323 Combi', - 5 => '323 Coupé', - 6 => '323 F', - 7 => '5', - 8 => '6', - 9 => '6 Combi', - 10 => '626', - 11 => '626 Combi', - 12 => 'B-Fighter', - 13 => 'B2500', - 14 => 'BT', - 15 => 'CX-3', - 16 => 'CX-5', - 17 => 'CX-7', - 18 => 'CX-9', - 19 => 'Demio', - 20 => 'MPV', - 21 => 'MX-3', - 22 => 'MX-5', - 23 => 'MX-6', - 24 => 'Premacy', - 25 => 'RX-7', - 26 => 'RX-8', - 27 => 'Xedox 6', - ], + 'brand' => 'Mazda', + 'models' => [ + 0 => '121', + 1 => '2', + 2 => '3', + 3 => '323', + 4 => '323 Combi', + 5 => '323 Coupé', + 6 => '323 F', + 7 => '5', + 8 => '6', + 9 => '6 Combi', + 10 => '626', + 11 => '626 Combi', + 12 => 'B-Fighter', + 13 => 'B2500', + 14 => 'BT', + 15 => 'CX-3', + 16 => 'CX-5', + 17 => 'CX-7', + 18 => 'CX-9', + 19 => 'Demio', + 20 => 'MPV', + 21 => 'MX-3', + 22 => 'MX-5', + 23 => 'MX-6', + 24 => 'Premacy', + 25 => 'RX-7', + 26 => 'RX-8', + 27 => 'Xedox 6', + ], ], 13 => [ - 'brand' => 'Mitsubishi', - 'models' => [ - 0 => '3000 GT', - 1 => 'ASX', - 2 => 'Carisma', - 3 => 'Colt', - 4 => 'Colt CC', - 5 => 'Eclipse', - 6 => 'Fuso canter', - 7 => 'Galant', - 8 => 'Galant Combi', - 9 => 'Grandis', - 10 => 'L200', - 11 => 'L200 Pick up', - 12 => 'L200 Pick up Allrad', - 13 => 'L300', - 14 => 'Lancer', - 15 => 'Lancer Combi', - 16 => 'Lancer Evo', - 17 => 'Lancer Sportback', - 18 => 'Outlander', - 19 => 'Pajero', - 20 => 'Pajeto Pinin', - 21 => 'Pajero Pinin Wagon', - 22 => 'Pajero Sport', - 23 => 'Pajero Wagon', - 24 => 'Space Star', - ], + 'brand' => 'Mitsubishi', + 'models' => [ + 0 => '3000 GT', + 1 => 'ASX', + 2 => 'Carisma', + 3 => 'Colt', + 4 => 'Colt CC', + 5 => 'Eclipse', + 6 => 'Fuso canter', + 7 => 'Galant', + 8 => 'Galant Combi', + 9 => 'Grandis', + 10 => 'L200', + 11 => 'L200 Pick up', + 12 => 'L200 Pick up Allrad', + 13 => 'L300', + 14 => 'Lancer', + 15 => 'Lancer Combi', + 16 => 'Lancer Evo', + 17 => 'Lancer Sportback', + 18 => 'Outlander', + 19 => 'Pajero', + 20 => 'Pajeto Pinin', + 21 => 'Pajero Pinin Wagon', + 22 => 'Pajero Sport', + 23 => 'Pajero Wagon', + 24 => 'Space Star', + ], ], 14 => [ - 'brand' => 'Lexus', - 'models' => [ - 0 => 'CT', - 1 => 'GS', - 2 => 'GS 300', - 3 => 'GX', - 4 => 'IS', - 5 => 'IS 200', - 6 => 'IS 250 C', - 7 => 'IS-F', - 8 => 'LS', - 9 => 'LX', - 10 => 'NX', - 11 => 'RC F', - 12 => 'RX', - 13 => 'RX 300', - 14 => 'RX 400h', - 15 => 'RX 450h', - 16 => 'SC 430', - ], + 'brand' => 'Lexus', + 'models' => [ + 0 => 'CT', + 1 => 'GS', + 2 => 'GS 300', + 3 => 'GX', + 4 => 'IS', + 5 => 'IS 200', + 6 => 'IS 250 C', + 7 => 'IS-F', + 8 => 'LS', + 9 => 'LX', + 10 => 'NX', + 11 => 'RC F', + 12 => 'RX', + 13 => 'RX 300', + 14 => 'RX 400h', + 15 => 'RX 450h', + 16 => 'SC 430', + ], ], 15 => [ - 'brand' => 'Toyota', - 'models' => [ - 0 => '4-Runner', - 1 => 'Auris', - 2 => 'Avensis', - 3 => 'Avensis Combi', - 4 => 'Avensis Van Verso', - 5 => 'Aygo', - 6 => 'Camry', - 7 => 'Carina', - 8 => 'Celica', - 9 => 'Corolla', - 10 => 'Corolla Combi', - 11 => 'Corolla sedan', - 12 => 'Corolla Verso', - 13 => 'FJ Cruiser', - 14 => 'GT86', - 15 => 'Hiace', - 16 => 'Hiace Van', - 17 => 'Highlander', - 18 => 'Hilux', - 19 => 'Land Cruiser', - 20 => 'MR2', - 21 => 'Paseo', - 22 => 'Picnic', - 23 => 'Prius', - 24 => 'RAV4', - 25 => 'Sequoia', - 26 => 'Starlet', - 27 => 'Supra', - 28 => 'Tundra', - 29 => 'Urban Cruiser', - 30 => 'Verso', - 31 => 'Yaris', - 32 => 'Yaris Verso', - ], + 'brand' => 'Toyota', + 'models' => [ + 0 => '4-Runner', + 1 => 'Auris', + 2 => 'Avensis', + 3 => 'Avensis Combi', + 4 => 'Avensis Van Verso', + 5 => 'Aygo', + 6 => 'Camry', + 7 => 'Carina', + 8 => 'Celica', + 9 => 'Corolla', + 10 => 'Corolla Combi', + 11 => 'Corolla sedan', + 12 => 'Corolla Verso', + 13 => 'FJ Cruiser', + 14 => 'GT86', + 15 => 'Hiace', + 16 => 'Hiace Van', + 17 => 'Highlander', + 18 => 'Hilux', + 19 => 'Land Cruiser', + 20 => 'MR2', + 21 => 'Paseo', + 22 => 'Picnic', + 23 => 'Prius', + 24 => 'RAV4', + 25 => 'Sequoia', + 26 => 'Starlet', + 27 => 'Supra', + 28 => 'Tundra', + 29 => 'Urban Cruiser', + 30 => 'Verso', + 31 => 'Yaris', + 32 => 'Yaris Verso', + ], ], 16 => [ - 'brand' => 'BMW', - 'models' => [ - 0 => 'i3', - 1 => 'i8', - 2 => 'M3', - 3 => 'M4', - 4 => 'M5', - 5 => 'M6', - 6 => 'Rad 1', - 7 => 'Rad 1 Cabrio', - 8 => 'Rad 1 Coupé', - 9 => 'Rad 2', - 10 => 'Rad 2 Active Tourer', - 11 => 'Rad 2 Coupé', - 12 => 'Rad 2 Gran Tourer', - 13 => 'Rad 3', - 14 => 'Rad 3 Cabrio', - 15 => 'Rad 3 Compact', - 16 => 'Rad 3 Coupé', - 17 => 'Rad 3 GT', - 18 => 'Rad 3 Touring', - 19 => 'Rad 4', - 20 => 'Rad 4 Cabrio', - 21 => 'Rad 4 Gran Coupé', - 22 => 'Rad 5', - 23 => 'Rad 5 GT', - 24 => 'Rad 5 Touring', - 25 => 'Rad 6', - 26 => 'Rad 6 Cabrio', - 27 => 'Rad 6 Coupé', - 28 => 'Rad 6 Gran Coupé', - 29 => 'Rad 7', - 30 => 'Rad 8 Coupé', - 31 => 'X1', - 32 => 'X3', - 33 => 'X4', - 34 => 'X5', - 35 => 'X6', - 36 => 'Z3', - 37 => 'Z3 Coupé', - 38 => 'Z3 Roadster', - 39 => 'Z4', - 40 => 'Z4 Roadster', - ], + 'brand' => 'BMW', + 'models' => [ + 0 => 'i3', + 1 => 'i8', + 2 => 'M3', + 3 => 'M4', + 4 => 'M5', + 5 => 'M6', + 6 => 'Rad 1', + 7 => 'Rad 1 Cabrio', + 8 => 'Rad 1 Coupé', + 9 => 'Rad 2', + 10 => 'Rad 2 Active Tourer', + 11 => 'Rad 2 Coupé', + 12 => 'Rad 2 Gran Tourer', + 13 => 'Rad 3', + 14 => 'Rad 3 Cabrio', + 15 => 'Rad 3 Compact', + 16 => 'Rad 3 Coupé', + 17 => 'Rad 3 GT', + 18 => 'Rad 3 Touring', + 19 => 'Rad 4', + 20 => 'Rad 4 Cabrio', + 21 => 'Rad 4 Gran Coupé', + 22 => 'Rad 5', + 23 => 'Rad 5 GT', + 24 => 'Rad 5 Touring', + 25 => 'Rad 6', + 26 => 'Rad 6 Cabrio', + 27 => 'Rad 6 Coupé', + 28 => 'Rad 6 Gran Coupé', + 29 => 'Rad 7', + 30 => 'Rad 8 Coupé', + 31 => 'X1', + 32 => 'X3', + 33 => 'X4', + 34 => 'X5', + 35 => 'X6', + 36 => 'Z3', + 37 => 'Z3 Coupé', + 38 => 'Z3 Roadster', + 39 => 'Z4', + 40 => 'Z4 Roadster', + ], ], 17 => [ - 'brand' => 'Volkswagen', - 'models' => [ - 0 => 'Amarok', - 1 => 'Beetle', - 2 => 'Bora', - 3 => 'Bora Variant', - 4 => 'Caddy', - 5 => 'Caddy Van', - 6 => 'Life', - 7 => 'California', - 8 => 'Caravelle', - 9 => 'CC', - 10 => 'Crafter', - 11 => 'Crafter Van', - 12 => 'Crafter Kombi', - 13 => 'CrossTouran', - 14 => 'Eos', - 15 => 'Fox', - 16 => 'Golf', - 17 => 'Golf Cabrio', - 18 => 'Golf Plus', - 19 => 'Golf Sportvan', - 20 => 'Golf Variant', - 21 => 'Jetta', - 22 => 'LT', - 23 => 'Lupo', - 24 => 'Multivan', - 25 => 'New Beetle', - 26 => 'New Beetle Cabrio', - 27 => 'Passat', - 28 => 'Passat Alltrack', - 29 => 'Passat CC', - 30 => 'Passat Variant', - 31 => 'Passat Variant Van', - 32 => 'Phaeton', - 33 => 'Polo', - 34 => 'Polo Van', - 35 => 'Polo Variant', - 36 => 'Scirocco', - 37 => 'Sharan', - 38 => 'T4', - 39 => 'T4 Caravelle', - 40 => 'T4 Multivan', - 41 => 'T5', - 42 => 'T5 Caravelle', - 43 => 'T5 Multivan', - 44 => 'T5 Transporter Shuttle', - 45 => 'Tiguan', - 46 => 'Touareg', - 47 => 'Touran', - ], + 'brand' => 'Volkswagen', + 'models' => [ + 0 => 'Amarok', + 1 => 'Beetle', + 2 => 'Bora', + 3 => 'Bora Variant', + 4 => 'Caddy', + 5 => 'Caddy Van', + 6 => 'Life', + 7 => 'California', + 8 => 'Caravelle', + 9 => 'CC', + 10 => 'Crafter', + 11 => 'Crafter Van', + 12 => 'Crafter Kombi', + 13 => 'CrossTouran', + 14 => 'Eos', + 15 => 'Fox', + 16 => 'Golf', + 17 => 'Golf Cabrio', + 18 => 'Golf Plus', + 19 => 'Golf Sportvan', + 20 => 'Golf Variant', + 21 => 'Jetta', + 22 => 'LT', + 23 => 'Lupo', + 24 => 'Multivan', + 25 => 'New Beetle', + 26 => 'New Beetle Cabrio', + 27 => 'Passat', + 28 => 'Passat Alltrack', + 29 => 'Passat CC', + 30 => 'Passat Variant', + 31 => 'Passat Variant Van', + 32 => 'Phaeton', + 33 => 'Polo', + 34 => 'Polo Van', + 35 => 'Polo Variant', + 36 => 'Scirocco', + 37 => 'Sharan', + 38 => 'T4', + 39 => 'T4 Caravelle', + 40 => 'T4 Multivan', + 41 => 'T5', + 42 => 'T5 Caravelle', + 43 => 'T5 Multivan', + 44 => 'T5 Transporter Shuttle', + 45 => 'Tiguan', + 46 => 'Touareg', + 47 => 'Touran', + ], ], 18 => [ - 'brand' => 'Suzuki', - 'models' => [ - 0 => 'Alto', - 1 => 'Baleno', - 2 => 'Baleno kombi', - 3 => 'Grand Vitara', - 4 => 'Grand Vitara XL-7', - 5 => 'Ignis', - 6 => 'Jimny', - 7 => 'Kizashi', - 8 => 'Liana', - 9 => 'Samurai', - 10 => 'Splash', - 11 => 'Swift', - 12 => 'SX4', - 13 => 'SX4 Sedan', - 14 => 'Vitara', - 15 => 'Wagon R+', - ], + 'brand' => 'Suzuki', + 'models' => [ + 0 => 'Alto', + 1 => 'Baleno', + 2 => 'Baleno kombi', + 3 => 'Grand Vitara', + 4 => 'Grand Vitara XL-7', + 5 => 'Ignis', + 6 => 'Jimny', + 7 => 'Kizashi', + 8 => 'Liana', + 9 => 'Samurai', + 10 => 'Splash', + 11 => 'Swift', + 12 => 'SX4', + 13 => 'SX4 Sedan', + 14 => 'Vitara', + 15 => 'Wagon R+', + ], ], 19 => [ - 'brand' => 'Mercedes-Benz', - 'models' => [ - 0 => '100 D', - 1 => '115', - 2 => '124', - 3 => '126', - 4 => '190', - 5 => '190 D', - 6 => '190 E', - 7 => '200 - 300', - 8 => '200 D', - 9 => '200 E', - 10 => '210 Van', - 11 => '210 kombi', - 12 => '310 Van', - 13 => '310 kombi', - 14 => '230 - 300 CE Coupé', - 15 => '260 - 560 SE', - 16 => '260 - 560 SEL', - 17 => '500 - 600 SEC Coupé', - 18 => 'Trieda A', - 19 => 'A', - 20 => 'A L', - 21 => 'AMG GT', - 22 => 'Trieda B', - 23 => 'Trieda C', - 24 => 'C', - 25 => 'C Sportcoupé', - 26 => 'C T', - 27 => 'Citan', - 28 => 'CL', - 29 => 'CL', - 30 => 'CLA', - 31 => 'CLC', - 32 => 'CLK Cabrio', - 33 => 'CLK Coupé', - 34 => 'CLS', - 35 => 'Trieda E', - 36 => 'E', - 37 => 'E Cabrio', - 38 => 'E Coupé', - 39 => 'E T', - 40 => 'Trieda G', - 41 => 'G Cabrio', - 42 => 'GL', - 43 => 'GLA', - 44 => 'GLC', - 45 => 'GLE', - 46 => 'GLK', - 47 => 'Trieda M', - 48 => 'MB 100', - 49 => 'Trieda R', - 50 => 'Trieda S', - 51 => 'S', - 52 => 'S Coupé', - 53 => 'SL', - 54 => 'SLC', - 55 => 'SLK', - 56 => 'SLR', - 57 => 'Sprinter', - ], + 'brand' => 'Mercedes-Benz', + 'models' => [ + 0 => '100 D', + 1 => '115', + 2 => '124', + 3 => '126', + 4 => '190', + 5 => '190 D', + 6 => '190 E', + 7 => '200 - 300', + 8 => '200 D', + 9 => '200 E', + 10 => '210 Van', + 11 => '210 kombi', + 12 => '310 Van', + 13 => '310 kombi', + 14 => '230 - 300 CE Coupé', + 15 => '260 - 560 SE', + 16 => '260 - 560 SEL', + 17 => '500 - 600 SEC Coupé', + 18 => 'Trieda A', + 19 => 'A', + 20 => 'A L', + 21 => 'AMG GT', + 22 => 'Trieda B', + 23 => 'Trieda C', + 24 => 'C', + 25 => 'C Sportcoupé', + 26 => 'C T', + 27 => 'Citan', + 28 => 'CL', + 29 => 'CL', + 30 => 'CLA', + 31 => 'CLC', + 32 => 'CLK Cabrio', + 33 => 'CLK Coupé', + 34 => 'CLS', + 35 => 'Trieda E', + 36 => 'E', + 37 => 'E Cabrio', + 38 => 'E Coupé', + 39 => 'E T', + 40 => 'Trieda G', + 41 => 'G Cabrio', + 42 => 'GL', + 43 => 'GLA', + 44 => 'GLC', + 45 => 'GLE', + 46 => 'GLK', + 47 => 'Trieda M', + 48 => 'MB 100', + 49 => 'Trieda R', + 50 => 'Trieda S', + 51 => 'S', + 52 => 'S Coupé', + 53 => 'SL', + 54 => 'SLC', + 55 => 'SLK', + 56 => 'SLR', + 57 => 'Sprinter', + ], ], 20 => [ - 'brand' => 'Saab', - 'models' => [ - 0 => '9-3', - 1 => '9-3 Cabriolet', - 2 => '9-3 Coupé', - 3 => '9-3 SportCombi', - 4 => '9-5', - 5 => '9-5 SportCombi', - 6 => '900', - 7 => '900 C', - 8 => '900 C Turbo', - 9 => '9000', - ], + 'brand' => 'Saab', + 'models' => [ + 0 => '9-3', + 1 => '9-3 Cabriolet', + 2 => '9-3 Coupé', + 3 => '9-3 SportCombi', + 4 => '9-5', + 5 => '9-5 SportCombi', + 6 => '900', + 7 => '900 C', + 8 => '900 C Turbo', + 9 => '9000', + ], ], 21 => [ - 'brand' => 'Audi', - 'models' => [ - 0 => '100', - 1 => '100 Avant', - 2 => '80', - 3 => '80 Avant', - 4 => '80 Cabrio', - 5 => '90', - 6 => 'A1', - 7 => 'A2', - 8 => 'A3', - 9 => 'A3 Cabriolet', - 10 => 'A3 Limuzina', - 11 => 'A3 Sportback', - 12 => 'A4', - 13 => 'A4 Allroad', - 14 => 'A4 Avant', - 15 => 'A4 Cabriolet', - 16 => 'A5', - 17 => 'A5 Cabriolet', - 18 => 'A5 Sportback', - 19 => 'A6', - 20 => 'A6 Allroad', - 21 => 'A6 Avant', - 22 => 'A7', - 23 => 'A8', - 24 => 'A8 Long', - 25 => 'Q3', - 26 => 'Q5', - 27 => 'Q7', - 28 => 'R8', - 29 => 'RS4 Cabriolet', - 30 => 'RS4/RS4 Avant', - 31 => 'RS5', - 32 => 'RS6 Avant', - 33 => 'RS7', - 34 => 'S3/S3 Sportback', - 35 => 'S4 Cabriolet', - 36 => 'S4/S4 Avant', - 37 => 'S5/S5 Cabriolet', - 38 => 'S6/RS6', - 39 => 'S7', - 40 => 'S8', - 41 => 'SQ5', - 42 => 'TT Coupé', - 43 => 'TT Roadster', - 44 => 'TTS', - ], + 'brand' => 'Audi', + 'models' => [ + 0 => '100', + 1 => '100 Avant', + 2 => '80', + 3 => '80 Avant', + 4 => '80 Cabrio', + 5 => '90', + 6 => 'A1', + 7 => 'A2', + 8 => 'A3', + 9 => 'A3 Cabriolet', + 10 => 'A3 Limuzina', + 11 => 'A3 Sportback', + 12 => 'A4', + 13 => 'A4 Allroad', + 14 => 'A4 Avant', + 15 => 'A4 Cabriolet', + 16 => 'A5', + 17 => 'A5 Cabriolet', + 18 => 'A5 Sportback', + 19 => 'A6', + 20 => 'A6 Allroad', + 21 => 'A6 Avant', + 22 => 'A7', + 23 => 'A8', + 24 => 'A8 Long', + 25 => 'Q3', + 26 => 'Q5', + 27 => 'Q7', + 28 => 'R8', + 29 => 'RS4 Cabriolet', + 30 => 'RS4/RS4 Avant', + 31 => 'RS5', + 32 => 'RS6 Avant', + 33 => 'RS7', + 34 => 'S3/S3 Sportback', + 35 => 'S4 Cabriolet', + 36 => 'S4/S4 Avant', + 37 => 'S5/S5 Cabriolet', + 38 => 'S6/RS6', + 39 => 'S7', + 40 => 'S8', + 41 => 'SQ5', + 42 => 'TT Coupé', + 43 => 'TT Roadster', + 44 => 'TTS', + ], ], 22 => [ - 'brand' => 'Kia', - 'models' => [ - 0 => 'Avella', - 1 => 'Besta', - 2 => 'Carens', - 3 => 'Carnival', - 4 => 'Cee`d', - 5 => 'Cee`d SW', - 6 => 'Cerato', - 7 => 'K 2500', - 8 => 'Magentis', - 9 => 'Opirus', - 10 => 'Optima', - 11 => 'Picanto', - 12 => 'Pregio', - 13 => 'Pride', - 14 => 'Pro Cee`d', - 15 => 'Rio', - 16 => 'Rio Combi', - 17 => 'Rio sedan', - 18 => 'Sephia', - 19 => 'Shuma', - 20 => 'Sorento', - 21 => 'Soul', - 22 => 'Sportage', - 23 => 'Venga', - ], + 'brand' => 'Kia', + 'models' => [ + 0 => 'Avella', + 1 => 'Besta', + 2 => 'Carens', + 3 => 'Carnival', + 4 => 'Cee`d', + 5 => 'Cee`d SW', + 6 => 'Cerato', + 7 => 'K 2500', + 8 => 'Magentis', + 9 => 'Opirus', + 10 => 'Optima', + 11 => 'Picanto', + 12 => 'Pregio', + 13 => 'Pride', + 14 => 'Pro Cee`d', + 15 => 'Rio', + 16 => 'Rio Combi', + 17 => 'Rio sedan', + 18 => 'Sephia', + 19 => 'Shuma', + 20 => 'Sorento', + 21 => 'Soul', + 22 => 'Sportage', + 23 => 'Venga', + ], ], 23 => [ - 'brand' => 'Land Rover', - 'models' => [ - 0 => '109', - 1 => 'Defender', - 2 => 'Discovery', - 3 => 'Discovery Sport', - 4 => 'Freelander', - 5 => 'Range Rover', - 6 => 'Range Rover Evoque', - 7 => 'Range Rover Sport', - ], + 'brand' => 'Land Rover', + 'models' => [ + 0 => '109', + 1 => 'Defender', + 2 => 'Discovery', + 3 => 'Discovery Sport', + 4 => 'Freelander', + 5 => 'Range Rover', + 6 => 'Range Rover Evoque', + 7 => 'Range Rover Sport', + ], ], 24 => [ - 'brand' => 'Dodge', - 'models' => [ - 0 => 'Avenger', - 1 => 'Caliber', - 2 => 'Challenger', - 3 => 'Charger', - 4 => 'Grand Caravan', - 5 => 'Journey', - 6 => 'Magnum', - 7 => 'Nitro', - 8 => 'RAM', - 9 => 'Stealth', - 10 => 'Viper', - ], + 'brand' => 'Dodge', + 'models' => [ + 0 => 'Avenger', + 1 => 'Caliber', + 2 => 'Challenger', + 3 => 'Charger', + 4 => 'Grand Caravan', + 5 => 'Journey', + 6 => 'Magnum', + 7 => 'Nitro', + 8 => 'RAM', + 9 => 'Stealth', + 10 => 'Viper', + ], ], 25 => [ - 'brand' => 'Chrysler', - 'models' => [ - 0 => '300 C', - 1 => '300 C Touring', - 2 => '300 M', - 3 => 'Crossfire', - 4 => 'Grand Voyager', - 5 => 'LHS', - 6 => 'Neon', - 7 => 'Pacifica', - 8 => 'Plymouth', - 9 => 'PT Cruiser', - 10 => 'Sebring', - 11 => 'Sebring Convertible', - 12 => 'Stratus', - 13 => 'Stratus Cabrio', - 14 => 'Town & Country', - 15 => 'Voyager', - ], + 'brand' => 'Chrysler', + 'models' => [ + 0 => '300 C', + 1 => '300 C Touring', + 2 => '300 M', + 3 => 'Crossfire', + 4 => 'Grand Voyager', + 5 => 'LHS', + 6 => 'Neon', + 7 => 'Pacifica', + 8 => 'Plymouth', + 9 => 'PT Cruiser', + 10 => 'Sebring', + 11 => 'Sebring Convertible', + 12 => 'Stratus', + 13 => 'Stratus Cabrio', + 14 => 'Town & Country', + 15 => 'Voyager', + ], ], 26 => [ - 'brand' => 'Ford', - 'models' => [ - 0 => 'Aerostar', - 1 => 'B-Max', - 2 => 'C-Max', - 3 => 'Cortina', - 4 => 'Cougar', - 5 => 'Edge', - 6 => 'Escort', - 7 => 'Escort Cabrio', - 8 => 'Escort kombi', - 9 => 'Explorer', - 10 => 'F-150', - 11 => 'F-250', - 12 => 'Fiesta', - 13 => 'Focus', - 14 => 'Focus C-Max', - 15 => 'Focus CC', - 16 => 'Focus kombi', - 17 => 'Fusion', - 18 => 'Galaxy', - 19 => 'Grand C-Max', - 20 => 'Ka', - 21 => 'Kuga', - 22 => 'Maverick', - 23 => 'Mondeo', - 24 => 'Mondeo Combi', - 25 => 'Mustang', - 26 => 'Orion', - 27 => 'Puma', - 28 => 'Ranger', - 29 => 'S-Max', - 30 => 'Sierra', - 31 => 'Street Ka', - 32 => 'Tourneo Connect', - 33 => 'Tourneo Custom', - 34 => 'Transit', - 35 => 'Transit', - 36 => 'Transit Bus', - 37 => 'Transit Connect LWB', - 38 => 'Transit Courier', - 39 => 'Transit Custom', - 40 => 'Transit kombi', - 41 => 'Transit Tourneo', - 42 => 'Transit Valnik', - 43 => 'Transit Van', - 44 => 'Transit Van 350', - 45 => 'Windstar', - ], + 'brand' => 'Ford', + 'models' => [ + 0 => 'Aerostar', + 1 => 'B-Max', + 2 => 'C-Max', + 3 => 'Cortina', + 4 => 'Cougar', + 5 => 'Edge', + 6 => 'Escort', + 7 => 'Escort Cabrio', + 8 => 'Escort kombi', + 9 => 'Explorer', + 10 => 'F-150', + 11 => 'F-250', + 12 => 'Fiesta', + 13 => 'Focus', + 14 => 'Focus C-Max', + 15 => 'Focus CC', + 16 => 'Focus kombi', + 17 => 'Fusion', + 18 => 'Galaxy', + 19 => 'Grand C-Max', + 20 => 'Ka', + 21 => 'Kuga', + 22 => 'Maverick', + 23 => 'Mondeo', + 24 => 'Mondeo Combi', + 25 => 'Mustang', + 26 => 'Orion', + 27 => 'Puma', + 28 => 'Ranger', + 29 => 'S-Max', + 30 => 'Sierra', + 31 => 'Street Ka', + 32 => 'Tourneo Connect', + 33 => 'Tourneo Custom', + 34 => 'Transit', + 35 => 'Transit', + 36 => 'Transit Bus', + 37 => 'Transit Connect LWB', + 38 => 'Transit Courier', + 39 => 'Transit Custom', + 40 => 'Transit kombi', + 41 => 'Transit Tourneo', + 42 => 'Transit Valnik', + 43 => 'Transit Van', + 44 => 'Transit Van 350', + 45 => 'Windstar', + ], ], 27 => [ - 'brand' => 'Hummer', - 'models' => [ - 0 => 'H2', - 1 => 'H3', - ], + 'brand' => 'Hummer', + 'models' => [ + 0 => 'H2', + 1 => 'H3', + ], ], 28 => [ - 'brand' => 'Hyundai', - 'models' => [ - 0 => 'Accent', - 1 => 'Atos', - 2 => 'Atos Prime', - 3 => 'Coupé', - 4 => 'Elantra', - 5 => 'Galloper', - 6 => 'Genesis', - 7 => 'Getz', - 8 => 'Grandeur', - 9 => 'H 350', - 10 => 'H1', - 11 => 'H1 Bus', - 12 => 'H1 Van', - 13 => 'H200', - 14 => 'i10', - 15 => 'i20', - 16 => 'i30', - 17 => 'i30 CW', - 18 => 'i40', - 19 => 'i40 CW', - 20 => 'ix20', - 21 => 'ix35', - 22 => 'ix55', - 23 => 'Lantra', - 24 => 'Matrix', - 25 => 'Santa Fe', - 26 => 'Sonata', - 27 => 'Terracan', - 28 => 'Trajet', - 29 => 'Tucson', - 30 => 'Veloster', - ], + 'brand' => 'Hyundai', + 'models' => [ + 0 => 'Accent', + 1 => 'Atos', + 2 => 'Atos Prime', + 3 => 'Coupé', + 4 => 'Elantra', + 5 => 'Galloper', + 6 => 'Genesis', + 7 => 'Getz', + 8 => 'Grandeur', + 9 => 'H 350', + 10 => 'H1', + 11 => 'H1 Bus', + 12 => 'H1 Van', + 13 => 'H200', + 14 => 'i10', + 15 => 'i20', + 16 => 'i30', + 17 => 'i30 CW', + 18 => 'i40', + 19 => 'i40 CW', + 20 => 'ix20', + 21 => 'ix35', + 22 => 'ix55', + 23 => 'Lantra', + 24 => 'Matrix', + 25 => 'Santa Fe', + 26 => 'Sonata', + 27 => 'Terracan', + 28 => 'Trajet', + 29 => 'Tucson', + 30 => 'Veloster', + ], ], 29 => [ - 'brand' => 'Infiniti', - 'models' => [ - 0 => 'EX', - 1 => 'FX', - 2 => 'G', - 3 => 'G Coupé', - 4 => 'M', - 5 => 'Q', - 6 => 'QX', - ], + 'brand' => 'Infiniti', + 'models' => [ + 0 => 'EX', + 1 => 'FX', + 2 => 'G', + 3 => 'G Coupé', + 4 => 'M', + 5 => 'Q', + 6 => 'QX', + ], ], 30 => [ - 'brand' => 'Jaguar', - 'models' => [ - 0 => 'Daimler', - 1 => 'F-Pace', - 2 => 'F-Type', - 3 => 'S-Type', - 4 => 'Sovereign', - 5 => 'X-Type', - 6 => 'X-type Estate', - 7 => 'XE', - 8 => 'XF', - 9 => 'XJ', - 10 => 'XJ12', - 11 => 'XJ6', - 12 => 'XJ8', - 13 => 'XJ8', - 14 => 'XJR', - 15 => 'XK', - 16 => 'XK8 Convertible', - 17 => 'XKR', - 18 => 'XKR Convertible', - ], + 'brand' => 'Jaguar', + 'models' => [ + 0 => 'Daimler', + 1 => 'F-Pace', + 2 => 'F-Type', + 3 => 'S-Type', + 4 => 'Sovereign', + 5 => 'X-Type', + 6 => 'X-type Estate', + 7 => 'XE', + 8 => 'XF', + 9 => 'XJ', + 10 => 'XJ12', + 11 => 'XJ6', + 12 => 'XJ8', + 13 => 'XJ8', + 14 => 'XJR', + 15 => 'XK', + 16 => 'XK8 Convertible', + 17 => 'XKR', + 18 => 'XKR Convertible', + ], ], 31 => [ - 'brand' => 'Jeep', - 'models' => [ - 0 => 'Cherokee', - 1 => 'Commander', - 2 => 'Compass', - 3 => 'Grand Cherokee', - 4 => 'Patriot', - 5 => 'Renegade', - 6 => 'Wrangler', - ], + 'brand' => 'Jeep', + 'models' => [ + 0 => 'Cherokee', + 1 => 'Commander', + 2 => 'Compass', + 3 => 'Grand Cherokee', + 4 => 'Patriot', + 5 => 'Renegade', + 6 => 'Wrangler', + ], ], 32 => [ - 'brand' => 'Nissan', - 'models' => [ - 0 => '100 NX', - 1 => '200 SX', - 2 => '350 Z', - 3 => '350 Z Roadster', - 4 => '370 Z', - 5 => 'Almera', - 6 => 'Almera Tino', - 7 => 'Cabstar E - T', - 8 => 'Cabstar TL2 Valnik', - 9 => 'e-NV200', - 10 => 'GT-R', - 11 => 'Insterstar', - 12 => 'Juke', - 13 => 'King Cab', - 14 => 'Leaf', - 15 => 'Maxima', - 16 => 'Maxima QX', - 17 => 'Micra', - 18 => 'Murano', - 19 => 'Navara', - 20 => 'Note', - 21 => 'NP300 Pickup', - 22 => 'NV200', - 23 => 'NV400', - 24 => 'Pathfinder', - 25 => 'Patrol', - 26 => 'Patrol GR', - 27 => 'Pickup', - 28 => 'Pixo', - 29 => 'Primastar', - 30 => 'Primastar Combi', - 31 => 'Primera', - 32 => 'Primera Combi', - 33 => 'Pulsar', - 34 => 'Qashqai', - 35 => 'Serena', - 36 => 'Sunny', - 37 => 'Terrano', - 38 => 'Tiida', - 39 => 'Trade', - 40 => 'Vanette Cargo', - 41 => 'X-Trail', - ], + 'brand' => 'Nissan', + 'models' => [ + 0 => '100 NX', + 1 => '200 SX', + 2 => '350 Z', + 3 => '350 Z Roadster', + 4 => '370 Z', + 5 => 'Almera', + 6 => 'Almera Tino', + 7 => 'Cabstar E - T', + 8 => 'Cabstar TL2 Valnik', + 9 => 'e-NV200', + 10 => 'GT-R', + 11 => 'Insterstar', + 12 => 'Juke', + 13 => 'King Cab', + 14 => 'Leaf', + 15 => 'Maxima', + 16 => 'Maxima QX', + 17 => 'Micra', + 18 => 'Murano', + 19 => 'Navara', + 20 => 'Note', + 21 => 'NP300 Pickup', + 22 => 'NV200', + 23 => 'NV400', + 24 => 'Pathfinder', + 25 => 'Patrol', + 26 => 'Patrol GR', + 27 => 'Pickup', + 28 => 'Pixo', + 29 => 'Primastar', + 30 => 'Primastar Combi', + 31 => 'Primera', + 32 => 'Primera Combi', + 33 => 'Pulsar', + 34 => 'Qashqai', + 35 => 'Serena', + 36 => 'Sunny', + 37 => 'Terrano', + 38 => 'Tiida', + 39 => 'Trade', + 40 => 'Vanette Cargo', + 41 => 'X-Trail', + ], ], 33 => [ - 'brand' => 'Volvo', - 'models' => [ - 0 => '240', - 1 => '340', - 2 => '360', - 3 => '460', - 4 => '850', - 5 => '850 kombi', - 6 => 'C30', - 7 => 'C70', - 8 => 'C70 Cabrio', - 9 => 'C70 Coupé', - 10 => 'S40', - 11 => 'S60', - 12 => 'S70', - 13 => 'S80', - 14 => 'S90', - 15 => 'V40', - 16 => 'V50', - 17 => 'V60', - 18 => 'V70', - 19 => 'V90', - 20 => 'XC60', - 21 => 'XC70', - 22 => 'XC90', - ], + 'brand' => 'Volvo', + 'models' => [ + 0 => '240', + 1 => '340', + 2 => '360', + 3 => '460', + 4 => '850', + 5 => '850 kombi', + 6 => 'C30', + 7 => 'C70', + 8 => 'C70 Cabrio', + 9 => 'C70 Coupé', + 10 => 'S40', + 11 => 'S60', + 12 => 'S70', + 13 => 'S80', + 14 => 'S90', + 15 => 'V40', + 16 => 'V50', + 17 => 'V60', + 18 => 'V70', + 19 => 'V90', + 20 => 'XC60', + 21 => 'XC70', + 22 => 'XC90', + ], ], 34 => [ - 'brand' => 'Daewoo', - 'models' => [ - 0 => 'Espero', - 1 => 'Kalos', - 2 => 'Lacetti', - 3 => 'Lanos', - 4 => 'Leganza', - 5 => 'Lublin', - 6 => 'Matiz', - 7 => 'Nexia', - 8 => 'Nubira', - 9 => 'Nubira kombi', - 10 => 'Racer', - 11 => 'Tacuma', - 12 => 'Tico', - ], + 'brand' => 'Daewoo', + 'models' => [ + 0 => 'Espero', + 1 => 'Kalos', + 2 => 'Lacetti', + 3 => 'Lanos', + 4 => 'Leganza', + 5 => 'Lublin', + 6 => 'Matiz', + 7 => 'Nexia', + 8 => 'Nubira', + 9 => 'Nubira kombi', + 10 => 'Racer', + 11 => 'Tacuma', + 12 => 'Tico', + ], ], 35 => [ - 'brand' => 'Fiat', - 'models' => [ - 0 => '1100', - 1 => '126', - 2 => '500', - 3 => '500L', - 4 => '500X', - 5 => '850', - 6 => 'Barchetta', - 7 => 'Brava', - 8 => 'Cinquecento', - 9 => 'Coupé', - 10 => 'Croma', - 11 => 'Doblo', - 12 => 'Doblo Cargo', - 13 => 'Doblo Cargo Combi', - 14 => 'Ducato', - 15 => 'Ducato Van', - 16 => 'Ducato Kombi', - 17 => 'Ducato Podvozok', - 18 => 'Florino', - 19 => 'Florino Combi', - 20 => 'Freemont', - 21 => 'Grande Punto', - 22 => 'Idea', - 23 => 'Linea', - 24 => 'Marea', - 25 => 'Marea Weekend', - 26 => 'Multipla', - 27 => 'Palio Weekend', - 28 => 'Panda', - 29 => 'Panda Van', - 30 => 'Punto', - 31 => 'Punto Cabriolet', - 32 => 'Punto Evo', - 33 => 'Punto Van', - 34 => 'Qubo', - 35 => 'Scudo', - 36 => 'Scudo Van', - 37 => 'Scudo Kombi', - 38 => 'Sedici', - 39 => 'Seicento', - 40 => 'Stilo', - 41 => 'Stilo Multiwagon', - 42 => 'Strada', - 43 => 'Talento', - 44 => 'Tipo', - 45 => 'Ulysse', - 46 => 'Uno', - 47 => 'X1/9', - ], + 'brand' => 'Fiat', + 'models' => [ + 0 => '1100', + 1 => '126', + 2 => '500', + 3 => '500L', + 4 => '500X', + 5 => '850', + 6 => 'Barchetta', + 7 => 'Brava', + 8 => 'Cinquecento', + 9 => 'Coupé', + 10 => 'Croma', + 11 => 'Doblo', + 12 => 'Doblo Cargo', + 13 => 'Doblo Cargo Combi', + 14 => 'Ducato', + 15 => 'Ducato Van', + 16 => 'Ducato Kombi', + 17 => 'Ducato Podvozok', + 18 => 'Florino', + 19 => 'Florino Combi', + 20 => 'Freemont', + 21 => 'Grande Punto', + 22 => 'Idea', + 23 => 'Linea', + 24 => 'Marea', + 25 => 'Marea Weekend', + 26 => 'Multipla', + 27 => 'Palio Weekend', + 28 => 'Panda', + 29 => 'Panda Van', + 30 => 'Punto', + 31 => 'Punto Cabriolet', + 32 => 'Punto Evo', + 33 => 'Punto Van', + 34 => 'Qubo', + 35 => 'Scudo', + 36 => 'Scudo Van', + 37 => 'Scudo Kombi', + 38 => 'Sedici', + 39 => 'Seicento', + 40 => 'Stilo', + 41 => 'Stilo Multiwagon', + 42 => 'Strada', + 43 => 'Talento', + 44 => 'Tipo', + 45 => 'Ulysse', + 46 => 'Uno', + 47 => 'X1/9', + ], ], 36 => [ - 'brand' => 'MINI', - 'models' => [ - 0 => 'Cooper', - 1 => 'Cooper Cabrio', - 2 => 'Cooper Clubman', - 3 => 'Cooper D', - 4 => 'Cooper D Clubman', - 5 => 'Cooper S', - 6 => 'Cooper S Cabrio', - 7 => 'Cooper S Clubman', - 8 => 'Countryman', - 9 => 'Mini One', - 10 => 'One D', - ], + 'brand' => 'MINI', + 'models' => [ + 0 => 'Cooper', + 1 => 'Cooper Cabrio', + 2 => 'Cooper Clubman', + 3 => 'Cooper D', + 4 => 'Cooper D Clubman', + 5 => 'Cooper S', + 6 => 'Cooper S Cabrio', + 7 => 'Cooper S Clubman', + 8 => 'Countryman', + 9 => 'Mini One', + 10 => 'One D', + ], ], 37 => [ - 'brand' => 'Rover', - 'models' => [ - 0 => '200', - 1 => '214', - 2 => '218', - 3 => '25', - 4 => '400', - 5 => '414', - 6 => '416', - 7 => '620', - 8 => '75', - ], + 'brand' => 'Rover', + 'models' => [ + 0 => '200', + 1 => '214', + 2 => '218', + 3 => '25', + 4 => '400', + 5 => '414', + 6 => '416', + 7 => '620', + 8 => '75', + ], ], 38 => [ - 'brand' => 'Smart', - 'models' => [ - 0 => 'Cabrio', - 1 => 'City-Coupé', - 2 => 'Compact Pulse', - 3 => 'Forfour', - 4 => 'Fortwo cabrio', - 5 => 'Fortwo coupé', - 6 => 'Roadster', - ], + 'brand' => 'Smart', + 'models' => [ + 0 => 'Cabrio', + 1 => 'City-Coupé', + 2 => 'Compact Pulse', + 3 => 'Forfour', + 4 => 'Fortwo cabrio', + 5 => 'Fortwo coupé', + 6 => 'Roadster', + ], ], - ]; + ]; } - } diff --git a/routes/web.php b/routes/web.php index e157056..d602dc3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,14 +1,15 @@ group(function () { Route::get('/', [ContractController::class, 'dashboard'])->name('dashboard'); @@ -68,17 +69,16 @@ Route::middleware(['auth:sanctum', 'verified'])->group(function () { Route::get('restore', [ContractController::class, 'restore'])->name('contracts.restore'); Route::get('print', [ContractController::class, 'print'])->name('contracts.print'); - Route::prefix('payments')->group(function () { + Route::prefix('payments')->group(function () { Route::get('create', [PaymentController::class, 'create'])->name('payments.create'); Route::delete('delete', [PaymentController::class, 'destroy'])->name('payments.destroy'); Route::post('/', [PaymentController::class, 'store'])->name('payments.store'); Route::get('{payment}/print', [PaymentController::class, 'print'])->name('payments.print'); }); - }); }); - Route::prefix('documents')->group(function () { + Route::prefix('documents')->group(function () { Route::get('{document}', [DocumentController::class, 'show'])->name('documents.show'); Route::delete('delete', [DocumentController::class, 'destroy'])->name('documents.destroy'); Route::post('upload', [DocumentController::class, 'store'])->name('documents.store');