*/ use HasFactory, Notifiable, TwoFactorAuthenticatable; protected $attributes = [ 'can_create_channel' => false, ]; protected $appends = [ 'avatar', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'two_factor_confirmed_at' => 'datetime', 'is_admin' => 'boolean', 'can_create_channel' => 'boolean', 'suspended_at' => 'datetime', ]; } public function channel(): HasOne { return $this->hasOne(Channel::class); } public function follows(): HasMany { return $this->hasMany(Follow::class); } public function supportConversations(): HasMany { return $this->hasMany(SupportConversation::class); } public function supportMessages(): HasMany { return $this->hasMany(SupportMessage::class); } public function isSuspended(): bool { return $this->suspended_at !== null; } public function canCreateChannel(): bool { return $this->can_create_channel || PlatformSetting::current()->channel_creation_open; } /** * @return Attribute */ protected function avatar(): Attribute { return Attribute::get(fn (): ?string => $this->avatar_path ? Storage::url($this->avatar_path) : null); } }