Improve display of user on accessory show page

This commit is contained in:
Marcus Moore
2025-05-21 16:48:26 -07:00
parent e3ffe79c4c
commit 5f883310b5
3 changed files with 21 additions and 6 deletions
@@ -220,7 +220,10 @@ class AccessoriesController extends Controller
*/
public function show(Accessory $accessory) : View | RedirectResponse
{
$accessory = Accessory::withCount('checkouts as checkouts_count')->find($accessory->id);
$accessory->loadCount('checkouts as checkouts_count');
$accessory->load(['adminuser' => fn($query) => $query->withTrashed()]);
$this->authorize('view', $accessory);
return view('accessories.view', compact('accessory'));
}
+1 -5
View File
@@ -324,11 +324,7 @@
</strong>
</div>
<div class="col-md-9" style="word-wrap: break-word;">
@if ($accessory->adminuser)
{{ $accessory->adminuser->present()->fullName() }}
@else
{{ trans('admin/reports/general.deleted_user') }}
@endif
<x-full-user-name :user="$accessory->adminuser" />
</div>
</div>
@@ -0,0 +1,16 @@
@props([
'user'
])
@if ($user)
@if (! $user->trashed())
{{-- if the user is in database but soft-deleted --}}
<a href="{{ route('users.show', $user->id) }}">{{ $user->present()->fullName() }}</a>
@else
{{-- if the user exists --}}
<s><a href="{{ route('users.show', $user->id) }}">{{ $user->present()->fullName() }}</a></s>
@endif
@else
{{-- if the user does not exist --}}
<span>Unknown User</span>
@endif