Merge pull request #13586 from inietov/fixes/call_to_member_function_checkedOutToUser

Fixed Call to a member function checkedOutToUser() on null [rollbar-3598]
This commit is contained in:
snipe 2023-09-12 08:35:30 +01:00 committed by GitHub
commit f6a11ac0ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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];