mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 17:14:10 -08:00
Check that the user exists before trying to print
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
26f28a862a
commit
b06c527767
|
@ -601,19 +601,15 @@ class UsersController extends Controller
|
||||||
/**
|
/**
|
||||||
* Print inventory
|
* Print inventory
|
||||||
*
|
*
|
||||||
* @author Aladin Alaily
|
|
||||||
* @since [v1.8]
|
* @since [v1.8]
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @author Aladin Alaily
|
||||||
*/
|
*/
|
||||||
public function printInventory($id)
|
public function printInventory($id)
|
||||||
{
|
{
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
$user = User::where('id', $id)->withTrashed()->first();
|
if ($user = User::where('id', $id)->withTrashed()->first()) {
|
||||||
|
|
||||||
|
|
||||||
// Make sure they can view this particular 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();
|
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||||
$accessories = $user->accessories()->get();
|
$accessories = $user->accessories()->get();
|
||||||
$consumables = $user->consumables()->get();
|
$consumables = $user->consumables()->get();
|
||||||
|
@ -626,6 +622,10 @@ class UsersController extends Controller
|
||||||
->with('settings', Setting::getSettings());
|
->with('settings', Setting::getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emails user a list of assigned assets
|
* Emails user a list of assigned assets
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue