diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 421e07b4ef..7cbbbdb10b 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -628,14 +628,16 @@ class UsersController extends Controller { $this->authorize('view', User::class); - if( User::where('id', $id)->first()->exists()) - { - $user= User::where('id', $id)->first(); - $user->notify((new CurrentInventory($user))); - return redirect()->back()->with('success', trans('admin/users/general.user_notified')); - } + if (!$user = User::find($id)) { + return redirect()->back() + ->with('error', trans('admin/users/message.user_not_found', ['id' => $id])); + } + if (empty($user->email)) { + return redirect()->back()->with('error', trans('admin/users/message.user_has_no_email')); + } - return redirect()->back()->with('error', 'admin/accessories/message.user_does_not_exist'); + $user->notify((new CurrentInventory($user))); + return redirect()->back()->with('success', trans('admin/users/general.user_notified')); } /** diff --git a/resources/lang/en/admin/users/message.php b/resources/lang/en/admin/users/message.php index 85d016f04a..29f82db38b 100644 --- a/resources/lang/en/admin/users/message.php +++ b/resources/lang/en/admin/users/message.php @@ -14,6 +14,7 @@ return array( 'ldap_not_configured' => 'LDAP integration has not been configured for this installation.', 'password_resets_sent' => 'The selected users who are activated and have a valid email addresses have been sent a password reset link.', 'password_reset_sent' => 'A password reset link has been sent to :email!', + 'user_has_no_email' => 'This user does not have an email address in their profile.', 'success' => array( @@ -58,4 +59,4 @@ return array( 'invalidfiles' => 'One or more of your files is too large or is a filetype that is not allowed. Allowed filetypes are png, gif, jpg, doc, docx, pdf, and txt.', ), -); +); \ No newline at end of file diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 616ab70890..8763c5718f 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -184,12 +184,16 @@ @endcan @can('view', $user) -
-
- {{ csrf_field() }} - -
-
+
+ @if(!empty($user->email)) +
+ {{ csrf_field() }} + +
+ @else + + @endif +
@endcan @can('update', $user)