*/ use HasFactory, Notifiable; use SoftDeletes; // use Audittable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'username', 'email', 'whatsapp_number', 'profile_photo_file_id', 'password', 'is_master', 'access_level', 'status', 'verification_channel', 'verification_target', 'verification_code', 'verification_code_expires_at', 'verified_at', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'is_master' => 'boolean', 'access_level' => UserAccessLevel::class, 'verification_code_expires_at' => 'datetime', 'verified_at' => 'datetime', ]; } public function menuGroups() { return $this->belongsToMany( MenuGroup::class, 'user_menu_groups', 'user_id', 'menu_group_id' )->withPivot(['tenant_id'])->withTimestamps(); } public function userProfile() { return $this->hasOne(UserProfile::class, 'user_id'); } public function profilePhoto() { return $this->belongsTo(StoredFile::class, 'profile_photo_file_id'); } public function userTenants() { return $this->hasMany(UserTenant::class, 'user_id'); } public function userMenuGroups() { return $this->hasMany(UserMenuGroup::class, 'user_id'); } public function userNotifications() { return $this->hasMany(UserNotification::class, 'user_id'); } public function wallets() { return $this->morphMany(Wallet::class, 'owner'); } public function isMasterAdmin(): bool { return $this->is_master || $this->access_level === UserAccessLevel::MASTER_ADMIN; } public function isTenantOwner(): bool { return $this->access_level === UserAccessLevel::TENANT_OWNER; } } // { // "email": "master@services-core.local", // "password": "Master@12345" // }