diff --git a/app/Enums/InvoiceTypes.php b/app/Enums/InvoiceTypes.php index 40a9d0b..a6e3f91 100644 --- a/app/Enums/InvoiceTypes.php +++ b/app/Enums/InvoiceTypes.php @@ -4,20 +4,31 @@ enum InvoiceTypes: string { - case EARNING = 'Tržba'; - case EXPENSE = 'Výdaj'; - case SALARY = 'Mzda'; - case VOUCHER = 'Poukaz'; - case OTHER = 'Ostatní'; + case EARNING = 'T'; + case EXPENSE = 'V'; + case SALARY = 'M'; + case VOUCHER = 'P'; + case OTHER = 'O'; + + public function getReadableFormat(): string + { + return match ($this) { + self::EARNING => 'Tržba', + self::EXPENSE => 'Výdaj', + self::SALARY => 'Mzda', + self::VOUCHER => 'Poukaz', + default => 'Ostatní' + }; + } public static function getHtmlSpan(string $type): string { return match ($type) { - 'T' => ''.self::EARNING->value.'', - 'V' => ''.self::EXPENSE->value.'', - 'M' => ''.self::SALARY->value.'', - 'P' => ''.self::VOUCHER->value.'', - default => ''.self::OTHER->value.'', + 'T' => ''.self::EARNING->getReadableFormat().'', + 'V' => ''.self::EXPENSE->getReadableFormat().'', + 'M' => ''.self::SALARY->getReadableFormat().'', + 'P' => ''.self::VOUCHER->getReadableFormat().'', + default => ''.self::OTHER->getReadableFormat().'', }; } } diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 2ee1cad..453a8d9 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -43,6 +43,18 @@ public function show(string $id): BinaryFileResponse return response()->download(storage_path('app/public/invoice/'.$id.'.png')); } + public function create(): View + { + return view('admin.invoices.create'); + } + + public function store(Request $request): RedirectResponse + { + Invoice::create($request->all()); + + return to_route('invoices.index')->with('success', 'Faktura byla úspěšně vytvořena.'); + } + /** * Show the form for editing the specified resource. */ diff --git a/resources/views/admin/customers/create.latte b/resources/views/admin/customers/create.latte index 0bc77d5..501cdfe 100644 --- a/resources/views/admin/customers/create.latte +++ b/resources/views/admin/customers/create.latte @@ -41,7 +41,7 @@
diff --git a/resources/views/admin/customers/edit.latte b/resources/views/admin/customers/edit.latte index 9d8c332..a5aaa41 100644 --- a/resources/views/admin/customers/edit.latte +++ b/resources/views/admin/customers/edit.latte @@ -43,7 +43,7 @@ diff --git a/resources/views/admin/invoices/create.latte b/resources/views/admin/invoices/create.latte new file mode 100644 index 0000000..f74e57b --- /dev/null +++ b/resources/views/admin/invoices/create.latte @@ -0,0 +1,43 @@ +{layout '../../layout.latte'} + +{block content} +