Merge pull request #1 from NateMS/shift-build-2463

Your Shifty Build
shift-build-2464
Nadim Salloum 2022-02-17 11:20:48 +00:00 committed by GitHub
commit 4890b393a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 1376 additions and 1364 deletions

View File

@ -14,5 +14,6 @@ use BenSampo\Enum\Enum;
final class ContractType extends Enum
{
const BuyContract = '0';
const SellContract = '1';
}

View File

@ -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';
}

View File

@ -11,6 +11,8 @@ use BenSampo\Enum\Enum;
final class PaymentType extends Enum
{
const Transaction = '0';
const Cash = '1';
const Cembra = '2';
}

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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,
@ -224,48 +229,41 @@ 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')
->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')
->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);
}
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.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.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)
@ -304,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);
}
@ -316,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')]);
}
@ -337,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,
@ -392,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);
}),
],
]);
}
@ -440,6 +443,7 @@ class CarController extends Controller
{
$this->updateCar($request, $car);
session()->flash('flash.banner', 'Auto geändert.');
return Redirect::route('cars.show', $car);
}
@ -450,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'],
@ -476,6 +480,7 @@ class CarController extends Controller
{
$car->delete();
session()->flash('flash.banner', 'Auto gelöscht.');
return Redirect::route('cars.show', $car);
}
@ -483,6 +488,7 @@ class CarController extends Controller
{
$car->restore();
session()->flash('flash.banner', 'Auto wiederhergestellt.');
return Redirect::route('cars.show', $car);
}
}

View File

@ -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)
@ -130,18 +131,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)
@ -165,6 +161,7 @@ class ContactController extends Controller
);
session()->flash('flash.banner', 'Kontakt erstellt.');
return Redirect::route('contacts.show', $contact);
}
@ -207,7 +204,7 @@ class ContactController extends Controller
'city' => $contact->city,
'country' => $contact->country,
'deleted_at' => $contact->deleted_at,
]
],
]);
}
@ -244,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,
@ -275,6 +278,7 @@ class ContactController extends Controller
);
session()->flash('flash.banner', 'Kontakt geändert.');
return Redirect::route('contacts.show', $contact);
}
@ -298,6 +302,7 @@ class ContactController extends Controller
{
$contact->delete();
session()->flash('flash.banner', 'Kontakt gelöscht.');
return Redirect::back();
}
@ -305,6 +310,7 @@ class ContactController extends Controller
{
$contact->restore();
session()->flash('flash.banner', 'Kontakt wiederhergestellt.');
return Redirect::back();
}
}

View File

@ -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);
}
}

View File

@ -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
{

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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');
}
}

View File

@ -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();
});
}

View File

@ -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();

View File

@ -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,50 +47,39 @@ 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);
}
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)
@ -98,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()
@ -164,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);
}
}

View File

@ -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()

View File

@ -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,27 +42,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()

View File

@ -1,32 +1,33 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\ServiceProvider;
class MorphServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Relation::morphMap([
'contracts' => 'App\Models\Contract',
'cars' => 'App\Models\Car',
'contacts' => 'App\Models\Contact',
]);
}
/**
* 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()
{
//
//
}
}

View File

@ -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);
});

View File

@ -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,
],
];

View File

@ -14,6 +14,6 @@ return [
'custom' => [
// 'MY1' => 2,
// 'MY2' => 3
]
]
],
],
];

View File

@ -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(),

View File

@ -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
{

View File

@ -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',

View File

@ -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(),
];
}
}

View File

@ -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
{
/**

View File

@ -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()),
];
}

View File

@ -1,10 +1,10 @@
<?php
use App\Enums\ContractType;
use App\Enums\InsuranceType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Enums\InsuranceType;
use App\Enums\ContractType;
class CreateContractsTable extends Migration
{

View File

@ -1,9 +1,9 @@
<?php
use App\Enums\PaymentType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Enums\PaymentType;
class CreatePaymentsTable extends Migration
{

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
<?php
use App\Http\Controllers\ContactController;
use App\Http\Controllers\CarController;
use App\Http\Controllers\BrandController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\CarController;
use App\Http\Controllers\CarModelController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\ContractController;
use App\Http\Controllers\DocumentController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\ReportController;
use Illuminate\Support\Facades\Route;
Route::middleware(['auth:sanctum', 'verified'])->group(function () {
@ -69,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');
@ -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');
});
});