*/ use HasFactory, Notifiable; protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } public function projects(): BelongsToMany { return $this->belongsToMany(Project::class) ->withPivot('role') ->withTimestamps(); } public function ownedProjects(): BelongsToMany { return $this->projects()->wherePivot('role', 'owner'); } public function notificationPreferences(): HasMany { return $this->hasMany(NotificationPreference::class); } public function notificationPreferenceFor(Project $project): NotificationPreference { return $this->notificationPreferences() ->firstOrCreate( ['project_id' => $project->id], ['email_enabled' => true, 'database_enabled' => true, 'muted' => false], ); } }