*/ use HasFactory, Notifiable; use HasUlids; // generates ULIDs automatically protected $keyType = 'string'; public $incrementing = false; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', ]; /** * 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', ]; } /** * A user can own many calendars. */ public function calendars(): HasMany { return $this->hasMany(Calendar::class); } /** * get the current user's principal uri */ public function getPrincipalUriAttribute(): string { return 'principals/' . $this->email; } /** * get all user addresses */ public function addresses() { return $this->hasMany(\App\Models\UserAddress::class, 'user_id', 'id'); } /** * get the user's billing address */ public function billingAddress() { return $this->addresses() ->where('kind', 'billing') ->where('is_primary', 1) ->first(); } }