This commit is contained in:
Stefanescu Mihai
2026-03-19 19:47:06 +02:00
parent e8d2728d57
commit eb735a9a98
19 changed files with 860 additions and 9 deletions
+15
View File
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -37,4 +38,18 @@ class User extends Authenticatable
{
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],
);
}
}