From f05407b0ef11152f4f62f1011fee99ce3eaae691 Mon Sep 17 00:00:00 2001 From: myuqinurrohman Date: Tue, 22 Apr 2025 14:13:14 +0700 Subject: [PATCH] feat: print data --- .../Dashboard/ContentRecapController.php | 11 + .../Dashboard/DatatableController.php | 6 + .../views/dashboard/companies/print.blade.php | 2 +- .../dashboard/content-recaps/print.blade.php | 214 ++++++++++++++++++ .../dashboard/journalists/print.blade.php | 2 +- .../views/dashboard/media/print.blade.php | 2 +- routes/web.php | 1 + 7 files changed, 235 insertions(+), 3 deletions(-) create mode 100644 resources/views/dashboard/content-recaps/print.blade.php diff --git a/app/Http/Controllers/Dashboard/ContentRecapController.php b/app/Http/Controllers/Dashboard/ContentRecapController.php index 11390dd..a188ab9 100644 --- a/app/Http/Controllers/Dashboard/ContentRecapController.php +++ b/app/Http/Controllers/Dashboard/ContentRecapController.php @@ -7,6 +7,7 @@ use App\Http\Requests\ContentRecapRequest; use App\Models\ContentRecap; use App\Models\ContentRecapClassification; +use Barryvdh\DomPDF\Facade\Pdf; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -139,4 +140,14 @@ public function export(Request $request) return Excel::download(new ContentRecapExport($classification, $channel, $social_media, $posted_year, $posted_month, $posted_date), 'content-recaps-'.$formattedNow.'.xlsx'); } + + public function printData($id){ + + $contentRecap = ContentRecap::with(['enhancer', 'classification'])->findOrFail(decrypt_id($id)); + + + $pdf = Pdf::loadView('dashboard.content-recaps.print', compact('contentRecap')); + + return $pdf->stream(slugify('rekap konten '. $contentRecap->content_theme).'.pdf'); + } } diff --git a/app/Http/Controllers/Dashboard/DatatableController.php b/app/Http/Controllers/Dashboard/DatatableController.php index 8d91600..35c57fb 100644 --- a/app/Http/Controllers/Dashboard/DatatableController.php +++ b/app/Http/Controllers/Dashboard/DatatableController.php @@ -2156,6 +2156,8 @@ public function contentRecap(Request $request){ ->addColumn('action', function ($data) { $showUrl = route('dashboard.content.recaps.show', ['id' => encrypt_id($data->id)]); + $printUrl = route('dashboard.content.recaps.print', ['id' => encrypt_id($data->id)]); + $editUrl = route('dashboard.content.recaps.edit', ['id' => encrypt_id($data->id)]); $deleteUrl = route('dashboard.content.recaps.destroy', ['id' => encrypt_id($data->id)]); @@ -2166,6 +2168,10 @@ public function contentRecap(Request $request){