diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 3b242f093e..191f371564 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -933,12 +933,17 @@ class ReportsController extends Controller /** * Get all assets with pending checkout acceptances */ - - $acceptances = CheckoutAcceptance::pending()->with('assignedTo')->get(); + if($showDeleted) { + $acceptances = CheckoutAcceptance::pending()->withTrashed()->with(['assignedTo' , 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } else { + $acceptances = CheckoutAcceptance::pending()->with(['assignedTo' => function ($query) { + $query->withTrashed(); + }, 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } $assetsForReport = $acceptances - ->filter(function($acceptance) { - return $acceptance->checkoutable_type == 'App\Models\Asset' && !is_null($acceptance->assignedTo); + ->filter(function ($acceptance) { + return $acceptance->checkoutable_type == 'App\Models\Asset'; }) ->map(function($acceptance) { return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance]; diff --git a/resources/views/reports/unaccepted_assets.blade.php b/resources/views/reports/unaccepted_assets.blade.php index 275a1c8425..37ae66ce30 100644 --- a/resources/views/reports/unaccepted_assets.blade.php +++ b/resources/views/reports/unaccepted_assets.blade.php @@ -71,7 +71,7 @@ @if ($item['assetItem']) trashed()) style="text-decoration: line-through" @endif> {{ $item['acceptance']->created_at }} - {{ ($item['assetItem']->company) ? $assetItem->company->name : '' }} + {{ ($item['assetItem']->company) ? $item['assetItem']->company->name : '' }} {!! $item['assetItem']->model->category->present()->nameUrl() !!} {!! $item['assetItem']->present()->modelUrl() !!} {!! $item['assetItem']->present()->nameUrl() !!}