From 04462db32b3a7b47ddfb4f2cbcc9a584222e12a5 Mon Sep 17 00:00:00 2001 From: hildaaaevs <149044919+hildaaaevs@users.noreply.github.com> Date: Fri, 30 May 2025 21:06:28 +0700 Subject: [PATCH] tambah download pdf --- app/Filament/Pages/Dashboard.php | 18 -- app/Filament/Resources/ReservasiiResource.php | 41 ++- app/Providers/Filament/AdminPanelProvider.php | 2 + composer.json | 1 + composer.lock | 299 +++++++++++++++++- database/seeders/PaketFotoSeeder.php | 4 +- .../views/components/layouts/app.blade.php | 1 + .../views/livewire/auth/login-page.blade.php | 2 +- resources/views/livewire/histori.blade.php | 8 +- resources/views/pdf/reservasi.blade.php | 100 ++++++ 10 files changed, 441 insertions(+), 35 deletions(-) delete mode 100644 app/Filament/Pages/Dashboard.php create mode 100644 resources/views/pdf/reservasi.blade.php diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php deleted file mode 100644 index 560afaf..0000000 --- a/app/Filament/Pages/Dashboard.php +++ /dev/null @@ -1,18 +0,0 @@ -bulkActions([ - //Tables\Actions\BulkActionGroup::make([ - //Tables\Actions\DeleteBulkAction::make(), - //]), - // ]) - //->defaultSort('created_at', 'desc'); - + ]) + ->headerActions([ + Tables\Actions\Action::make('downloadPdf') + ->label('Download PDF') + ->icon('heroicon-o-document-arrow-down') + ->form([ + DatePicker::make('start_date') + ->label('Tanggal Mulai') + ->required(), + DatePicker::make('end_date') + ->label('Tanggal Selesai') + ->required(), + ]) + ->action(function (array $data) { + $reservasis = Reservasii::with(['user', 'detail.paketFoto']) + ->whereBetween('tanggal', [$data['start_date'], $data['end_date']]) + ->get(); + + $pdf = Pdf::loadView('pdf.reservasi', [ + 'reservasis' => $reservasis, + 'start_date' => $data['start_date'], + 'end_date' => $data['end_date'] + ]); + + return response()->streamDownload(function () use ($pdf) { + echo $pdf->output(); + }, 'reservasi.pdf'); + }) + ]); + } public static function getRelations(): array { diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 3de14c7..793f0cb 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -23,6 +23,8 @@ class AdminPanelProvider extends PanelProvider { + protected static ?string $navigationLabel = 'Dashboard'; + public function panel(Panel $panel): Panel { return $panel diff --git a/composer.json b/composer.json index 03b30ec..b0930c5 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "license": "MIT", "require": { "php": "^8.2", + "barryvdh/laravel-dompdf": "^3.1", "filament/filament": "^3.2", "laravel/framework": "^11.31", "laravel/tinker": "^2.9", diff --git a/composer.lock b/composer.lock index f02ac6f..e7d3ae8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "be7f3b11976e7d288f560860af33c3ac", + "content-hash": "888cb519a7bf5bc3e0fa714989a74c28", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -72,6 +72,83 @@ }, "time": "2025-01-27T15:13:13+00:00" }, + { + "name": "barryvdh/laravel-dompdf", + "version": "v3.1.1", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-dompdf.git", + "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d", + "reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d", + "shasum": "" + }, + "require": { + "dompdf/dompdf": "^3.0", + "illuminate/support": "^9|^10|^11|^12", + "php": "^8.1" + }, + "require-dev": { + "larastan/larastan": "^2.7|^3.0", + "orchestra/testbench": "^7|^8|^9|^10", + "phpro/grumphp": "^2.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf", + "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf" + }, + "providers": [ + "Barryvdh\\DomPDF\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\DomPDF\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "A DOMPDF Wrapper for Laravel", + "keywords": [ + "dompdf", + "laravel", + "pdf" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-dompdf/issues", + "source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.1.1" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-02-13T15:07:54+00:00" + }, { "name": "blade-ui-kit/blade-heroicons", "version": "2.6.0", @@ -850,6 +927,161 @@ ], "time": "2024-02-05T11:56:58+00:00" }, + { + "name": "dompdf/dompdf", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "a51bd7a063a65499446919286fb18b518177155a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/a51bd7a063a65499446919286fb18b518177155a", + "reference": "a51bd7a063a65499446919286fb18b518177155a", + "shasum": "" + }, + "require": { + "dompdf/php-font-lib": "^1.0.0", + "dompdf/php-svg-lib": "^1.0.0", + "ext-dom": "*", + "ext-mbstring": "*", + "masterminds/html5": "^2.0", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "ext-gd": "*", + "ext-json": "*", + "ext-zip": "*", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" + }, + "suggest": { + "ext-gd": "Needed to process images", + "ext-gmagick": "Improves image processing performance", + "ext-imagick": "Improves image processing performance", + "ext-zlib": "Needed for pdf stream compression" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dompdf\\": "src/" + }, + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "The Dompdf Community", + "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md" + } + ], + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "support": { + "issues": "https://github.com/dompdf/dompdf/issues", + "source": "https://github.com/dompdf/dompdf/tree/v3.1.0" + }, + "time": "2025-01-15T14:09:04+00:00" + }, + { + "name": "dompdf/php-font-lib", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-font-lib.git", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "FontLib\\": "src/FontLib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "The FontLib Community", + "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/dompdf/php-font-lib", + "support": { + "issues": "https://github.com/dompdf/php-font-lib/issues", + "source": "https://github.com/dompdf/php-font-lib/tree/1.0.1" + }, + "time": "2024-12-02T14:37:59+00:00" + }, + { + "name": "dompdf/php-svg-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-svg-lib.git", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabberworm/php-css-parser": "^8.4" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Svg\\": "src/Svg" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "The SvgLib Community", + "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse and export to PDF SVG files.", + "homepage": "https://github.com/dompdf/php-svg-lib", + "support": { + "issues": "https://github.com/dompdf/php-svg-lib/issues", + "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0" + }, + "time": "2024-04-29T13:26:35+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v3.4.0", @@ -4716,6 +4948,71 @@ ], "time": "2024-02-26T18:08:49+00:00" }, + { + "name": "sabberworm/php-css-parser", + "version": "v8.8.0", + "source": { + "type": "git", + "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", + "reference": "3de493bdddfd1f051249af725c7e0d2c38fed740" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/3de493bdddfd1f051249af725c7e0d2c38fed740", + "reference": "3de493bdddfd1f051249af725c7e0d2c38fed740", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": "^5.6.20 || ^7.0.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.41" + }, + "suggest": { + "ext-mbstring": "for parsing UTF-8 CSS" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabberworm\\CSS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raphael Schweikert" + }, + { + "name": "Oliver Klee", + "email": "github@oliverklee.de" + }, + { + "name": "Jake Hotson", + "email": "jake.github@qzdesign.co.uk" + } + ], + "description": "Parser for CSS Files written in PHP", + "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "keywords": [ + "css", + "parser", + "stylesheet" + ], + "support": { + "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", + "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.8.0" + }, + "time": "2025-03-23T17:59:05+00:00" + }, { "name": "spatie/color", "version": "1.8.0", diff --git a/database/seeders/PaketFotoSeeder.php b/database/seeders/PaketFotoSeeder.php index e600a92..2c910ac 100644 --- a/database/seeders/PaketFotoSeeder.php +++ b/database/seeders/PaketFotoSeeder.php @@ -20,7 +20,7 @@ public function run(): void 'nama_paket_foto' => 'Paket Pasangan', 'harga_paket_foto' => '75000', 'fasilitas' => '20 menit foto, 1x cetak foto single frame', - 'gambar' => '01JMC5FASB77HCJQHGNNS56X3P.jpg', + 'gambar' => '.jpg', 'status' => true, 'created_at' => now(), 'updated_at' => now() @@ -40,7 +40,7 @@ public function run(): void 'nama_paket_foto' => 'Widebox Couple', 'harga_paket_foto' => '50000', 'fasilitas' => '10 menit foto, 1x cetak foto 4R', - 'gambar' => 'platinum.jpg', + 'gambar' => 'pasangan.jpg', 'status' => true, 'created_at' => now(), 'updated_at' => now() diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index 8d5fc30..f156640 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -3,6 +3,7 @@
+Sudah punya akun? Daftar
+Belum punya akun? Daftar
> diff --git a/resources/views/livewire/histori.blade.php b/resources/views/livewire/histori.blade.php index 04ac5fa..5d8f87b 100644 --- a/resources/views/livewire/histori.blade.php +++ b/resources/views/livewire/histori.blade.php @@ -1,5 +1,5 @@Order | +Id | Tanggal | Waktu | Paket Foto | -Status Pembayaran | +Tipe Pembayaran | Total | -Action | +Aksi |
---|
No | +Nama | +Tanggal | +Waktu | +Paket Foto | +Total | +Tipe Pembayaran | +Metode Pembayaran | +
---|---|---|---|---|---|---|---|
{{ $index + 1 }} | +{{ $reservasi->nama }} | +{{ $reservasi->tanggal->format('d F Y') }} | +{{ $reservasi->waktu }} | +
+ @foreach($reservasi->detail as $detail)
+ {{ $detail->paketFoto->nama_paket_foto }} + @endforeach + |
+ Rp {{ number_format($reservasi->total, 0, ',', '.') }} | +{{ ucfirst($reservasi->tipe_pembayaran) }} | +{{ ucfirst($reservasi->metode_pembayaran) }} | +