*/ use HasFactory, SoftDeletes; use HasRoles; use Notifiable; use TwoFactorAuthenticatable; public function restrictedPermissions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { return $this->belongsToMany( \Spatie\Permission\Models\Permission::class, 'restricted_user_permissions', 'user_id', 'permission_id' )->withPivot('role_id')->withTimestamps(); } /** * Get the user's initials */ public function initials(): string { return Str::of($this->name) ->explode(' ') ->take(2) ->map(fn ($word) => Str::substr($word, 0, 1)) ->implode(''); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'keka_ms_token_expires_at' => 'datetime', ]; } /** * @return HasMany */ public function oauthTokens(): HasMany { return $this->hasMany(OauthToken::class); } /** * Get the OAuth token for a specific provider. */ public function oauthToken(string $provider): ?OauthToken { return $this->oauthTokens()->forProvider($provider)->first(); } }