Fixed RB-21535 - use withTrashed for maintenances on Activity Report

This commit is contained in:
snipe
2026-05-19 08:38:03 +01:00
parent 5dcc8efcca
commit be5b74af90
2 changed files with 11 additions and 7 deletions
@@ -39,15 +39,15 @@ class ReportsController extends Controller
if ((! Gate::allows('activity.view')) && (($request->filled('target_type')) && ($request->filled('target_id'))) || (($request->filled('item_type')) && ($request->filled('item_id')))) {
if (($request->filled('target_type')) && ($request->filled('target_id'))) {
$target = Helper::normalizeFullModelName(request()->input('target_type'));
$target::find(request()->input('target_id'))?->withTrashed();
$this->authorize('view', $target);
$targetClass = Helper::normalizeFullModelName(request()->input('target_type'));
$target = $targetClass::withTrashed()->find(request()->input('target_id'));
$this->authorize('view', $target ?? $targetClass);
}
if (($request->filled('item_type')) && ($request->filled('item_id'))) {
$item = Helper::normalizeFullModelName(request()->input('item_type'));
$item::find(request()->input('item_id'))?->withTrashed();
$this->authorize('view', $item);
$itemClass = Helper::normalizeFullModelName(request()->input('item_type'));
$item = $itemClass::withTrashed()->find(request()->input('item_id'));
$this->authorize('view', $item ?? $itemClass);
}
} else {
+5 -1
View File
@@ -37,8 +37,12 @@ final class MaintenancePolicy
* Determine whether the user can view a specific maintenance record.
* Allowed if the user can edit the associated asset.
*/
public function view(User $user, Maintenance $maintenance): bool
public function view(User $user, ?Maintenance $maintenance = null): bool
{
if (is_null($maintenance)) {
return $user->hasAccess('assets.view');
}
return Gate::allows('update', $maintenance->asset);
}