diff --git a/app/Models/User.php b/app/Models/User.php index 8211fabd63..c3f7f80b94 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -338,6 +338,24 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo return $this->belongsToMany(\App\Models\License::class, 'license_seats', 'assigned_to', 'license_id')->withPivot('id'); } + /** + * Establishes a count of all items assigned + * + * @author J. Vinsmoke + * @since [v6.1] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + Public function allAssignedCount() { + $assetsCount = $this->assets()->count(); + $licensesCount = $this->licenses()->count(); + $accessoriesCount = $this->accessories()->count(); + $consumablesCount = $this->consumables()->count(); + + $totalCount = $assetsCount + $licensesCount + $accessoriesCount + $consumablesCount; + + return (int) $totalCount; + } + /** * Establishes the user -> actionlogs relationship * diff --git a/resources/lang/en/admin/users/message.php b/resources/lang/en/admin/users/message.php index 11292a0697..247a1b321e 100644 --- a/resources/lang/en/admin/users/message.php +++ b/resources/lang/en/admin/users/message.php @@ -15,6 +15,7 @@ return array( '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.', + 'user_has_no_assets_assigned' => 'This user does not have any assets assigned', 'success' => array( diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 4455154499..17bc7bdf18 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -179,17 +179,23 @@ @can('view', $user)