From 9cbd2d032c6cf882619288eb0a703f1709c1acf6 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 11 Sep 2023 17:40:59 -0600 Subject: [PATCH] Add a boolean variable and condition to handle the call to checkedOutToUser() method --- app/Http/Controllers/ReportsController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 6bb7aa35cf..bacc27f423 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -1021,7 +1021,12 @@ class ReportsController extends Controller $assetsForReport = $acceptances ->filter(function ($acceptance) { - return $acceptance->checkoutable_type == 'App\Models\Asset' && $acceptance->checkoutable->checkedOutToUser(); + $acceptance_checkoutable_flag = false; + if ($acceptance->checkoutable){ + $acceptance_checkoutable_flag = $acceptance->checkoutable->checkedOutToUser(); + } + + return $acceptance->checkoutable_type == 'App\Models\Asset' && $acceptance_checkoutable_flag; }) ->map(function($acceptance) { return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance];