mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-17 00:51:04 +02:00
Control & Promote administrator status via a method rather than a prop
This commit is contained in:
@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Laragear\WebAuthn\WebAuthnAuthentication;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
|
||||
@ -86,6 +87,27 @@ class User extends Authenticatable implements WebAuthnAuthenticatable
|
||||
return $query->where('is_admin', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is an administrator.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAdministrator()
|
||||
{
|
||||
return $this->is_admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant administrator permissions to the user.
|
||||
*
|
||||
* @param bool $promote
|
||||
* @return void
|
||||
*/
|
||||
public function promoteToAdministrator(bool $promote = true)
|
||||
{
|
||||
$this->is_admin = $promote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
|
Reference in New Issue
Block a user