From eb67d1b064229528a1629d9e16b1860ff0f5345a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 6 Dec 2022 18:00:16 -0600 Subject: [PATCH] Filter items from the report if null returned --- app/Http/Controllers/ReportsController.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 45c87ac31c..7751b2450a 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -1110,13 +1110,19 @@ class ReportsController extends Controller $rows[] = implode(',', $header); foreach ($assetsForReport as $item) { - $row = [ ]; - $row[] = str_replace(',', '', e($item['assetItem']->model->category->name)); - $row[] = str_replace(',', '', e($item['assetItem']->model->name)); - $row[] = str_replace(',', '', e($item['assetItem']->name)); - $row[] = str_replace(',', '', e($item['assetItem']->asset_tag)); - $row[] = str_replace(',', '', e(($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->name() : trans('admin/reports/general.deleted_user'))); - $rows[] = implode(',', $row); + + if ($item['assetItem'] != null){ + + $row = [ ]; + $row[] = str_replace(',', '', e($item['assetItem']->model->category->name)); + $row[] = str_replace(',', '', e($item['assetItem']->model->name)); + $row[] = str_replace(',', '', e($item['assetItem']->name)); + $row[] = str_replace(',', '', e($item['assetItem']->asset_tag)); + $row[] = str_replace(',', '', e(($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->name() : trans('admin/reports/general.deleted_user'))); + $rows[] = implode(',', $row); + } else { + // Log the error maybe? + } } // spit out a csv