From 6b6ad12bb7ff4cf82b3df76709722fe5e50c5211 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 10 Mar 2023 15:58:05 +0100 Subject: [PATCH] Add an Admin scope to retrieve Admin users easily --- app/Models/User.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index 1bf800b0..1ea07ecc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -73,6 +73,17 @@ class User extends Authenticatable implements WebAuthnAuthenticatable 'twofaccounts_count' => 'integer', 'groups_count' => 'integer', ]; + + /** + * Scope a query to only include admin users. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeAdmins($query) + { + return $query->where('is_admin', true); + } /** * Send the password reset notification.