*/ protected $fillable = [ 'company_id', 'username', 'name', 'email', 'password', 'phone', 'avatar', 'role', 'status', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; /** * Get the login logs for the user. */ public function loginLogs() { return $this->hasMany(\App\Models\UserLoginLog::class); } /** * Get the company that owns the user. */ public function company() { return $this->belongsTo(Company::class); } /** * Check if the user is a system administrator. */ public function isSystemAdmin(): bool { return is_null($this->company_id); } /** * Check if the user belongs to a tenant. */ public function isTenant(): bool { return !is_null($this->company_id); } }