From e37cad669965fa3c11f7ba5f9663670a6e706fef Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 4 Oct 2025 15:37:28 +0200 Subject: [PATCH] new: make the eye icon work to see an invoice in admin customer view --- .../Admin/Shop/CustomerInvoicesDataTable.php | 2 +- .../Admin/Shop/CustomerInvoiceController.php | 9 --------- .../Controllers/Shop/InvoiceController.php | 8 +++++++- app/Repositories/Shop/Invoices.php | 8 +++++++- .../Shop/CustomerInvoices/list.blade.php | 20 +++++++++++++++++++ routes/Admin/Shop/CustomerInvoices.php | 1 - 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/Datatables/Admin/Shop/CustomerInvoicesDataTable.php b/app/Datatables/Admin/Shop/CustomerInvoicesDataTable.php index f9992525..3b464076 100644 --- a/app/Datatables/Admin/Shop/CustomerInvoicesDataTable.php +++ b/app/Datatables/Admin/Shop/CustomerInvoicesDataTable.php @@ -11,7 +11,7 @@ use Yajra\DataTables\Html\Column; class CustomerInvoicesDataTable extends DataTable { - public $model_name = 'invoices'; + public $model_name = 'customer_invoices'; public $sortedColumn = 1; diff --git a/app/Http/Controllers/Admin/Shop/CustomerInvoiceController.php b/app/Http/Controllers/Admin/Shop/CustomerInvoiceController.php index cc43aa7f..403cc189 100644 --- a/app/Http/Controllers/Admin/Shop/CustomerInvoiceController.php +++ b/app/Http/Controllers/Admin/Shop/CustomerInvoiceController.php @@ -12,15 +12,6 @@ class CustomerInvoiceController extends Controller return $dataTable->render('Admin.Shop.CustomerInvoices.list'); } - public function show($id) - { - $data = [ - 'invoice' => Invoices::get($id), - ]; - - return view('Admin.Shop.CustomerInvoices.view', $data); - } - public function destroy($id) { return Invoices::destroy($id); diff --git a/app/Http/Controllers/Shop/InvoiceController.php b/app/Http/Controllers/Shop/InvoiceController.php index 1250b97e..d22a6379 100644 --- a/app/Http/Controllers/Shop/InvoiceController.php +++ b/app/Http/Controllers/Shop/InvoiceController.php @@ -15,8 +15,14 @@ class InvoiceController extends Controller public function view($uuid) { + $invoice = Invoices::view($uuid); + + if (! $invoice) { + abort(404); + } + $data = [ - 'invoice' => Invoices::view($uuid), + 'invoice' => $invoice, ]; return view('Shop.Invoices.view', $data); diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index aee0edab..6925f563 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -36,7 +36,13 @@ class Invoices public static function view($uuid) { - $data = self::getFullByUUID($uuid)->toArray(); + $invoice = self::getFullByUUID($uuid); + + if (! $invoice) { + return false; + } + + $data = $invoice->toArray(); $data['payment_type'] = InvoicePayments::getPaymentType($data['payment_type']); $data['status'] = self::getStatus($data['status']); diff --git a/resources/views/Admin/Shop/CustomerInvoices/list.blade.php b/resources/views/Admin/Shop/CustomerInvoices/list.blade.php index 373ad20d..f288efd3 100644 --- a/resources/views/Admin/Shop/CustomerInvoices/list.blade.php +++ b/resources/views/Admin/Shop/CustomerInvoices/list.blade.php @@ -4,8 +4,28 @@ 'model' => 'customer_invoices', 'with_print' => false, 'with_filters' => false, + 'show_callback' => 'AdminCustomerInvoiceView(id);', ]) @include('Admin.Shop.CustomerInvoices.partials.filters', ['model' => 'customer_invoices']) + +@include('load.layout.modal') + +@push('js') + +@endpush diff --git a/routes/Admin/Shop/CustomerInvoices.php b/routes/Admin/Shop/CustomerInvoices.php index f1fc87ba..cfac9773 100644 --- a/routes/Admin/Shop/CustomerInvoices.php +++ b/routes/Admin/Shop/CustomerInvoices.php @@ -3,5 +3,4 @@ Route::prefix('CustomerInvoices')->name('CustomerInvoices.')->group(function () { Route::get('', 'CustomerInvoiceController@index')->name('index'); Route::delete('destroy/{id?}', 'CustomerInvoiceController@destroy')->name('destroy'); - Route::get('view/{id?}', 'CustomerInvoiceController@view')->name('view'); });