This commit is contained in:
2026-03-20 21:17:26 +01:00
parent 1a62fcb81d
commit 29c3ff8572
229 changed files with 13147 additions and 2577 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Achievement;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class AchievementUnlockedNotification extends Notification
{
use Queueable;
public function __construct(private readonly Achievement $achievement) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'achievement_unlocked';
}
public function toDatabase(object $notifiable): array
{
return [
'type' => 'achievement_unlocked',
'achievement_id' => $this->achievement->id,
'achievement_slug' => $this->achievement->slug,
'title' => $this->achievement->name,
'icon' => $this->achievement->icon,
'message' => '🎉 You unlocked: ' . $this->achievement->name,
'xp_reward' => (int) $this->achievement->xp_reward,
'url' => '/dashboard?panel=achievements',
];
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Artwork;
use App\Models\ArtworkComment;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
class ArtworkCommentedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Artwork $artwork,
private readonly ArtworkComment $comment,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'artwork_commented';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
$slug = Str::slug((string) ($this->artwork->slug ?: $this->artwork->title)) ?: (string) $this->artwork->id;
return [
'type' => 'artwork_commented',
'artwork_id' => (int) $this->artwork->id,
'artwork_title' => $this->artwork->title,
'comment_id' => (int) $this->comment->id,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' commented on your artwork',
'url' => route('art.show', ['id' => $this->artwork->id, 'slug' => $slug]) . '#comment-' . $this->comment->id,
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Artwork;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
class ArtworkLikedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Artwork $artwork,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'artwork_liked';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
$slug = Str::slug((string) ($this->artwork->slug ?: $this->artwork->title)) ?: (string) $this->artwork->id;
return [
'type' => 'artwork_liked',
'artwork_id' => (int) $this->artwork->id,
'artwork_title' => $this->artwork->title,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' liked your artwork',
'url' => route('art.show', ['id' => $this->artwork->id, 'slug' => $slug]),
];
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Artwork;
use App\Models\ArtworkComment;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
class ArtworkMentionedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Artwork $artwork,
private readonly ArtworkComment $comment,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'artwork_mentioned';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
$slug = Str::slug((string) ($this->artwork->slug ?: $this->artwork->title)) ?: (string) $this->artwork->id;
return [
'type' => 'artwork_mentioned',
'artwork_id' => (int) $this->artwork->id,
'artwork_title' => $this->artwork->title,
'comment_id' => (int) $this->comment->id,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' mentioned you in an artwork comment',
'url' => route('art.show', ['id' => $this->artwork->id, 'slug' => $slug]) . '#comment-' . $this->comment->id,
];
}
}

View File

@@ -24,6 +24,11 @@ class ArtworkSharedNotification extends Notification implements ShouldQueue
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'artwork_shared';
}
public function toDatabase(object $notifiable): array
{
return [
@@ -34,7 +39,7 @@ class ArtworkSharedNotification extends Notification implements ShouldQueue
'sharer_id' => $this->sharer->id,
'sharer_name' => $this->sharer->name,
'sharer_username' => $this->sharer->username,
'message' => "{$this->sharer->name} shared your artwork "{$this->artwork->title}"",
'message' => $this->sharer->name . ' shared your artwork "' . $this->artwork->title . '"',
'url' => "/@{$this->sharer->username}?tab=posts",
];
}

View File

@@ -24,6 +24,11 @@ class PostCommentedNotification extends Notification implements ShouldQueue
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'post_commented';
}
public function toDatabase(object $notifiable): array
{
return [

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Story;
use App\Models\StoryComment;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class StoryCommentedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Story $story,
private readonly StoryComment $comment,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'story_commented';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'story_commented',
'story_id' => (int) $this->story->id,
'story_title' => $this->story->title,
'comment_id' => (int) $this->comment->id,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' commented on your story',
'url' => route('stories.show', ['slug' => $this->story->slug]) . '#story-comment-' . $this->comment->id,
];
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Story;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class StoryLikedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Story $story,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'story_liked';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'story_liked',
'story_id' => (int) $this->story->id,
'story_title' => $this->story->title,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' liked your story',
'url' => route('stories.show', ['slug' => $this->story->slug]),
];
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Story;
use App\Models\StoryComment;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class StoryMentionedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Story $story,
private readonly StoryComment $comment,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'story_mentioned';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'story_mentioned',
'story_id' => (int) $this->story->id,
'story_title' => $this->story->title,
'comment_id' => (int) $this->comment->id,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' mentioned you in a story comment',
'url' => route('stories.show', ['slug' => $this->story->slug]) . '#story-comment-' . $this->comment->id,
];
}
}

View File

@@ -24,6 +24,13 @@ class StoryStatusNotification extends Notification
return ['database'];
}
public function databaseType(object $notifiable): string
{
return in_array($this->event, ['approved', 'published'], true)
? 'story_published'
: 'story_status';
}
public function toDatabase(object $notifiable): array
{
$message = match ($this->event) {
@@ -34,7 +41,9 @@ class StoryStatusNotification extends Notification
};
return [
'type' => 'story.' . $this->event,
'type' => in_array($this->event, ['approved', 'published'], true)
? 'story_published'
: 'story.' . $this->event,
'story_id' => $this->story->id,
'title' => $this->story->title,
'slug' => $this->story->slug,

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class UserFollowedNotification extends Notification
{
use Queueable;
public function __construct(private readonly User $actor) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'user_followed';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'user_followed',
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' started following you',
'url' => $this->actor->username ? '/@' . $this->actor->username : null,
];
}
}