Filter items from the report if null returned

This commit is contained in:
Ivan Nieto Vivanco 2022-12-06 18:00:16 -06:00
parent b7a5467f8b
commit eb67d1b064

View file

@ -1110,6 +1110,9 @@ class ReportsController extends Controller
$rows[] = implode(',', $header); $rows[] = implode(',', $header);
foreach ($assetsForReport as $item) { foreach ($assetsForReport as $item) {
if ($item['assetItem'] != null){
$row = [ ]; $row = [ ];
$row[] = str_replace(',', '', e($item['assetItem']->model->category->name)); $row[] = str_replace(',', '', e($item['assetItem']->model->category->name));
$row[] = str_replace(',', '', e($item['assetItem']->model->name)); $row[] = str_replace(',', '', e($item['assetItem']->model->name));
@ -1117,6 +1120,9 @@ class ReportsController extends Controller
$row[] = str_replace(',', '', e($item['assetItem']->asset_tag)); $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'))); $row[] = str_replace(',', '', e(($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->name() : trans('admin/reports/general.deleted_user')));
$rows[] = implode(',', $row); $rows[] = implode(',', $row);
} else {
// Log the error maybe?
}
} }
// spit out a csv // spit out a csv