*/ protected $fillable = [ 'user_role_main', 'user_role_local_group', 'activation_token', 'activation_token_expires_at', 'username', 'local_group', 'firstname', 'nickname', 'lastname', 'membership_id', 'address_1', 'address_2', 'postcode', 'city', 'email', 'phone', 'birthday', 'medications', 'allergies', 'intolerances', 'eating_habits', 'swimming_permission', 'first_aid_permission', '$bank_account_owner', 'bank_account_iban', 'password', 'active', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'password' => 'hashed', ]; } public function getOfficialName() : string { return sprintf('%1$s %2$s', $this->firstname, $this->lastname); } public function getFullname() : string { return sprintf('%1$1s %2$s %3$s', $this->firstname, $this->lastname, $this->nickname !== null ? '(' . $this->nickname . ')' : '', ) |>trim(...); } public function getNicename() : string { return $this->nickname ?? $this->firstname; } public function localGroup() : Tenant { return $this->belongsTo(Tenant::class, 'local_group', 'slug')->first(); } public function costUnits() { return $this->belongsToMany(CostUnit::class, 'cost_unit_treasurers', 'user_id', 'cost_unit_id') ->withTimestamps(); } }