diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index fd21ebaf3a..dc2130e986 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -26,7 +26,10 @@ class AccessoriesController extends Controller */ public function index(Request $request) { - $this->authorize('view', Accessory::class); + if ($request->user()->cannot('reports.view')) { + $this->authorize('view', Accessory::class); + } + // This array is what determines which fields should be allowed to be sorted on ON the table itself, no relations // Relations will be handled in query scopes a little further down. diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 8e29498606..41b2f257c0 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -51,9 +51,8 @@ class ReportsController extends Controller public function getAccessoryReport() { $this->authorize('reports.view'); - $accessories = Accessory::orderBy('created_at', 'DESC')->with('company')->get(); - return view('reports/accessories', compact('accessories')); + return view('reports/accessories'); } /** diff --git a/resources/views/reports/accessories.blade.php b/resources/views/reports/accessories.blade.php index 49db62c7f6..44f90682ba 100644 --- a/resources/views/reports/accessories.blade.php +++ b/resources/views/reports/accessories.blade.php @@ -27,6 +27,7 @@ data-sort-order="asc" id="accessoriesReport" class="table table-striped snipe-table" + data-url="{{ route('api.accessories.index') }}" data-export-options='{ "fileName": "accessory-report-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] @@ -34,27 +35,17 @@ - {{ trans('admin/companies/table.title') }} - {{ trans('admin/accessories/table.title') }} - {{ trans('general.model_no') }} - {{ trans('admin/accessories/general.total') }} - {{ trans('admin/accessories/general.remaining') }} + {{ trans('admin/companies/table.title') }} + {{ trans('admin/accessories/table.title') }} + {{ trans('general.model_no') }} + {{ trans('admin/accessories/general.total') }} + {{ trans('admin/accessories/general.remaining') }} - @foreach ($accessories as $accessory) - - {{ is_null($accessory->company) ? '' : $accessory->company->name }} - {{ $accessory->name }} - {{ $accessory->model_number }} - {{ $accessory->qty }} - {{ $accessory->numRemaining() }} - - @endforeach -