mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Add eager loading
This commit is contained in:
parent
d7bde37842
commit
7ad4a29970
|
@ -597,17 +597,25 @@ class UsersController extends Controller
|
||||||
public function printInventory($id)
|
public function printInventory($id)
|
||||||
{
|
{
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
if ($user = User::where('id', $id)->withTrashed()->first()) {
|
|
||||||
|
|
||||||
|
$user = User::where('id', $id)
|
||||||
|
->with([
|
||||||
|
'assets',
|
||||||
|
'accessories',
|
||||||
|
'consumables',
|
||||||
|
'licenses',
|
||||||
|
])
|
||||||
|
->withTrashed()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
$this->authorize('view', $user);
|
$this->authorize('view', $user);
|
||||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
|
||||||
$accessories = $user->accessories()->get();
|
|
||||||
$consumables = $user->consumables()->get();
|
|
||||||
|
|
||||||
return view('users/print')->with('assets', $assets)
|
return view('users/print')
|
||||||
->with('licenses', $user->licenses()->get())
|
->with('assets', $user->assets)
|
||||||
->with('accessories', $accessories)
|
->with('licenses', $user->licenses)
|
||||||
->with('consumables', $consumables)
|
->with('accessories', $user->accessories)
|
||||||
|
->with('consumables', $user->consumables)
|
||||||
->with('show_user', $user)
|
->with('show_user', $user)
|
||||||
->with('settings', Setting::getSettings());
|
->with('settings', Setting::getSettings());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue