Merge pull request #11906 from inietov/fixes/server_error_downloading_unaccepted_assets

Fixed error 500 when downloading asset acceptance report. [sc-19555]
This commit is contained in:
snipe 2022-10-03 16:40:28 -07:00 committed by GitHub
commit e9224f094e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1083,9 +1083,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', 'checkoutable.assignedTo', 'checkoutable.model'])->get();
$acceptances = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get();
}
$assetsForReport = $acceptances