*/ protected $fillable = [ 'name', 'email', 'username', 'password', 'verification_code', 'verified', 'trial_ends_at', 'company_id', 'first_name', 'last_name', 'alias_name', 'phone', 'forgot_password_otp', 'status', 'role_id', 'api_token', 'admin_active_company_id' ]; /** * 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 = [ 'trial_ends_at' => 'datetime', ]; public function getRedirectRoute() { switch ($this->role_id) { case Role::OWNER_ROLE: return RouteServiceProvider::USER_HOME; case Role::ADMINISTRATOR_ROLE: return RouteServiceProvider::USER_HOME; case Role::BOOKKEEPER_ROLE: return RouteServiceProvider::USER_HOME; case Role::COMPANY_SECRETARY_ROLE: return RouteServiceProvider::USER_HOME; case Role::IT_PERSONNEL_ROLE: return RouteServiceProvider::ADMIN_HOME; case Role::NUMSTATION_MANAGER_ROLE: return RouteServiceProvider::ADMIN_HOME; case Role::NUMSTATION_STAFF_ROLE: return RouteServiceProvider::ADMIN_HOME; default: return RouteServiceProvider::USER_HOME; } } public function getRedirectRouteIfNotAuthenticated() { switch ($this->role_id) { case Role::OWNER_ROLE: return RouteServiceProvider::USER_LOGIN; case Role::ADMINISTRATOR_ROLE: return RouteServiceProvider::USER_LOGIN; case Role::BOOKKEEPER_ROLE: return RouteServiceProvider::USER_LOGIN; case Role::COMPANY_SECRETARY_ROLE: return RouteServiceProvider::USER_LOGIN; case Role::IT_PERSONNEL_ROLE: return RouteServiceProvider::ADMIN_LOGIN; case Role::NUMSTATION_MANAGER_ROLE: return RouteServiceProvider::ADMIN_LOGIN; case Role::NUMSTATION_STAFF_ROLE: return RouteServiceProvider::ADMIN_LOGIN; default: return RouteServiceProvider::USER_LOGIN; } } public function company() { return $this->belongsTo(Company::class); } public function notificationSettings() { return $this->hasMany(UserNotificationSetting::class); } public function userRole() { return $this->hasOne(Role::class, 'id', 'role_id'); } public function notifications() { return $this->hasMany(UserNotification::class); } public function adminActiveCompany() { return $this->hasOne(Company::class, 'id', 'admin_active_company_id'); } }