users menu listing
This commit is contained in:
+24
-38
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
@@ -14,33 +13,22 @@ use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\Contracts\PasskeyUser;
|
||||
use Laravel\Fortify\PasskeyAuthenticatable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Modules\Helpdesk\Concerns\HasHelpdeskTickets;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property string|null $two_factor_secret
|
||||
* @property string|null $two_factor_recovery_codes
|
||||
* @property Carbon|null $two_factor_confirmed_at
|
||||
* @property string|null $remember_token
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property bool $helpdesk_agent
|
||||
* @property bool $helpdesk_admin
|
||||
*/
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Fillable(['name', 'email', 'password', 'email_verified_at', 'helpdesk_agent', 'helpdesk_admin'])]
|
||||
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
|
||||
class User extends Authenticatable implements PasskeyUser
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, HasHelpdeskTickets, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
|
||||
use HasFactory, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -51,28 +39,6 @@ class User extends Authenticatable implements PasskeyUser
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards-compatible application-level admin check.
|
||||
*
|
||||
* Helpdesk currently owns the admin role, so this maps to the
|
||||
* Helpdesk admin permission flag.
|
||||
*/
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->isHelpdeskAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards-compatible application-level agent check.
|
||||
*/
|
||||
public function isAgent(): bool
|
||||
{
|
||||
return $this->isHelpdeskAgent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's initials
|
||||
*/
|
||||
public function initials(): string
|
||||
{
|
||||
$initials = Str::initials($this->name, true);
|
||||
@@ -81,4 +47,24 @@ class User extends Authenticatable implements PasskeyUser
|
||||
? Str::substr($initials, 0, 1).Str::substr($initials, -1)
|
||||
: $initials;
|
||||
}
|
||||
|
||||
public function isHelpdeskAdmin(): bool
|
||||
{
|
||||
return (bool) $this->helpdesk_admin;
|
||||
}
|
||||
|
||||
public function isHelpdeskAgent(): bool
|
||||
{
|
||||
return $this->isHelpdeskAdmin() || (bool) $this->helpdesk_agent;
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->isHelpdeskAdmin();
|
||||
}
|
||||
|
||||
public function isAgent(): bool
|
||||
{
|
||||
return $this->isHelpdeskAgent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user