Skip to content

User ​

File: src/Entities/User.php
Namespace: Unusualify\Modularous\Entities
Extends: Illuminate\Foundation\Auth\User (Authenticatable)
Implements: HasLocalePreference, MustVerifyEmail
Traits: HasApiTokens, HasFactory, HasRoles, IsTranslatable, ModelHelpers, Notifiable, HasFileponds, HasOauth, CanRegister, HasCompany

The primary authenticatable user model. Supports roles and permissions (via Spatie), API tokens (Sanctum), OAuth provider linking, company association, avatar via Filepond, and locale preferences.

Fillable Attributes ​

AttributeTypeDescription
namestringFirst name
surnamestringLast name
emailstringEmail address
passwordstringHashed password
company_idintAssociated company
job_titlestringJob title
languagestringPreferred locale
timezonestringPreferred timezone
phonestringPhone number
country_idintCountry reference
ui_preferencesarraySidebar/topbar preferences (JSON cast)
publishedboolActive/published status
email_verified_atdatetimeEmail verification timestamp

Hidden Attributes ​

password, remember_token

Appended Accessors ​

AccessorTypeDescription
roles_metaCollectionMinimal role data (id, name, title) for the current user
is_clientbooltrue if any role name starts with client
is_superadminbooltrue if user has the superadmin role

Boot Behaviour ​

  • Creating: sets a default password from DEFAULT_USER_PASSWORD env if none provided.
  • Updated: clears email_verified_at when the email changes.
  • Global scope: always eager-loads rolesMetaRelation.

Relationships ​

rolesMetaRelation(): BelongsToMany ​

Lightweight roles relation (only id, name, title columns) for the roles_meta accessor. Respects Spatie's team permission configuration.

Methods ​

setImpersonating($id) / stopImpersonating() / isImpersonating() ​

Session-based impersonation helpers.

sendGeneratePasswordNotification($token) / sendPasswordResetNotification($token) ​

Dispatches the corresponding notification with the given token.

preferredLocale(): string ​

Returns the user's language or the application's default locale.

avatar: string (accessor) ​

Returns the avatar Filepond upload URL or a default anonymous image.