Created method in users.php for adding up all assigned to user and providing an integer value. this then used to grey out buttons on user view if user has nothing assigned.
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user