From 50810ae31d1d2dba6c450ac10e8affea4ecc3311 Mon Sep 17 00:00:00 2001 From: SuperTapok Date: Sun, 31 Dec 2023 13:36:51 +0700 Subject: [PATCH 1/2] feat: :card_file_box: Removed server-side receipt storing --- app/Http/Controllers/CartController.php | 18 +++--------------- .../Controllers/TransactionsController.php | 2 +- resources/views/orders.blade.php | 2 +- resources/views/transactions.blade.php | 2 +- routes/web.php | 3 +-- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/CartController.php b/app/Http/Controllers/CartController.php index d403efd..e353881 100644 --- a/app/Http/Controllers/CartController.php +++ b/app/Http/Controllers/CartController.php @@ -125,13 +125,6 @@ public function pay ($employee_id, $order_id) { $employee->save(); $order->receipt_code = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 6); - $order->save(); - $order->refresh(); - - PDF::loadView('receipt_templates/receipt', - ['order' => $order, 'products' => $grouped_products])->save('storage/receipts/receipt_'.$order->receipt_code.'.pdf'); - - $order->receipt_url = 'storage/receipts/receipt_'.$order->receipt_code.'.pdf'; $order->save(); return $this->successResponse([ @@ -139,20 +132,15 @@ public function pay ($employee_id, $order_id) { 'order_id' => $order->id, ]); } - - - } - // TODO: переименовать и сделать public function getOrderPdf(Request $request) { $order = Order::find($request->get('order_id')); - return response()->file($order->receipt_url, [ - 'Content-Type' => 'application/pdf', - 'Content-Disposition' => 'inline; filename="receipt'.$order->receipt_code.'.pdf"' - ]); + $products = $order->products; + $grouped_products = $this->group_products($products); + return PDF::loadView('receipt_templates/receipt', ['order' => $order, 'products' => $grouped_products])->stream(); } } diff --git a/app/Http/Controllers/TransactionsController.php b/app/Http/Controllers/TransactionsController.php index b68b0ba..295e026 100644 --- a/app/Http/Controllers/TransactionsController.php +++ b/app/Http/Controllers/TransactionsController.php @@ -33,7 +33,7 @@ public function index() "type" => "order", "date" => $order->paid_at, "sum" => $order->sum, - "info" => $order->receipt_url + "info" => $order->id ]; $i++; } diff --git a/resources/views/orders.blade.php b/resources/views/orders.blade.php index 225d5ed..18197b0 100644 --- a/resources/views/orders.blade.php +++ b/resources/views/orders.blade.php @@ -61,7 +61,7 @@ @else {{ date('d.m.Y', strtotime($order->given_at)) }} @endif - Чек + Чек @endforeach diff --git a/resources/views/transactions.blade.php b/resources/views/transactions.blade.php index 1f13c55..354cd58 100644 --- a/resources/views/transactions.blade.php +++ b/resources/views/transactions.blade.php @@ -20,7 +20,7 @@ {{ date('d.m.Y', strtotime($transaction['date'])) }} @if ($transaction['type'] == 'order') -{{ $transaction['sum'] }} - Чек + Чек @else +{{ $transaction['sum'] }} {{ $transaction['info'] }} diff --git a/routes/web.php b/routes/web.php index 6303822..3e09518 100644 --- a/routes/web.php +++ b/routes/web.php @@ -81,8 +81,7 @@ Route::get('logout', [LogoutController::class, 'perform'])->name('logout'); - // TODO: - Route::get('order', [CartController::class,'getOrderPdf']); + Route::get('order', [CartController::class,'getOrderPdf'])->name('get_order');; Route::fallback(function () { return redirect(''); From fd2d35e7fae7289088e8e22887fbca92d7abfbd2 Mon Sep 17 00:00:00 2001 From: SuperTapok Date: Sun, 31 Dec 2023 13:52:02 +0700 Subject: [PATCH 2/2] docs: :memo: Edited README --- README.md | 84 ++++++++++++------------------------------------------- 1 file changed, 18 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 3ed385a..a80959b 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,18 @@ -

Laravel Logo

- -

-Build Status -Total Downloads -Latest Stable Version -License -

- -## About Laravel - -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: - -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). - -Laravel is accessible, powerful, and provides tools required for large, robust applications. - -## Learning Laravel - -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. - -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. - -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. - -## Laravel Sponsors - -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). - -### Premium Partners - -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Cubet Techno Labs](https://cubettech.com)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[Many](https://www.many.co.uk)** -- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** -- **[DevSquad](https://devsquad.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[OP.GG](https://op.gg)** -- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** -- **[Lendio](https://lendio.com)** - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. - -## License - -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +# CookiesShop +Дипломный проект, представляющий собой интернет-магазин, использующий внутреннюю валюту предприятия - "пряни". +## Используемые технологии +* PHP 8 Laravel 10; +* Bootstap5 + Blade; +* JS + HTML + CSS; +## Инструкция по установке +1. Скопировать репозиторий; +2. Добавить в корень проекта файл ```.env```, в котором указать настройки для вашей локальной системы - базу данных, локальный URL и т.д.; +3. В корне проекта в терминале вызвать ```composer install```; +4. А затем ```php artisan migrate```, ``` npm i```, ```npm run build```; +5. Для добавления статических файлов вызвать ```php artisan storage:link```; +6. И наконец ```php artisan server``` для запуска проекта на локальном сервере; +## Системные требования +1. PHP 8; +2. Composer; +3. NodeJS; +4. OpenServerPanel или другая база данных MySQL; \ No newline at end of file