Add an Admin scope to retrieve Admin users easily

This commit is contained in:
Bubka
2023-03-10 15:58:05 +01:00
parent a2e0c52189
commit 6b6ad12bb7

View File

@ -74,6 +74,17 @@ class User extends Authenticatable implements WebAuthnAuthenticatable
'groups_count' => 'integer',
];
/**
* Scope a query to only include admin users.
*
* @param \Illuminate\Database\Eloquent\Builder<User> $query
* @return \Illuminate\Database\Eloquent\Builder<User>
*/
public function scopeAdmins($query)
{
return $query->where('is_admin', true);
}
/**
* Send the password reset notification.
*