Merge pull request #11156 from inietov/fixes/error_500_on_unaccepeted_assets_report

Fixes error 500 on Unaccepted Assets Report
This commit is contained in:
snipe 2022-05-18 13:04:54 -07:00 committed by GitHub
commit b2250ecb7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -939,9 +939,9 @@ class ReportsController extends Controller
* Get all assets with pending checkout acceptances
*/
if($showDeleted) {
$acceptances = CheckoutAcceptance::pending()->withTrashed()->with(['assignedTo' , 'checkoutable.assignedTo', 'checkoutable.model'])->get();
$acceptances = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')->withTrashed()->with(['assignedTo' , 'checkoutable.assignedTo', 'checkoutable.model'])->get();
} else {
$acceptances = CheckoutAcceptance::pending()->with(['assignedTo' => function ($query) {
$acceptances = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')->with(['assignedTo' => function ($query) {
$query->withTrashed();
}, 'checkoutable.assignedTo', 'checkoutable.model'])->get();
}