Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor/rules/laravel-boost.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.

- php - 8.4.22
- php - 8.4.23
- filament/filament (FILAMENT) - v5
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v12
Expand Down
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.

- php - 8.4.22
- php - 8.4.23
- filament/filament (FILAMENT) - v5
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v12
Expand Down
2 changes: 1 addition & 1 deletion .junie/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.

- php - 8.4.22
- php - 8.4.23
- filament/filament (FILAMENT) - v5
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v12
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.

- php - 8.4.22
- php - 8.4.23
- filament/filament (FILAMENT) - v5
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v12
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.

- php - 8.4.22
- php - 8.4.23
- filament/filament (FILAMENT) - v5
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v12
Expand Down
5 changes: 5 additions & 0 deletions app/Livewire/Customer/Plugins/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
use App\Enums\PluginType;
use App\Jobs\ReviewPluginRepository;
use App\Models\Plugin;
use App\Notifications\PluginPendingReview;
use App\Notifications\PluginSubmitted;
use App\Services\GitHubUserService;
use Flux\Flux;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Computed;
Expand Down Expand Up @@ -164,6 +166,9 @@ public function submitForReview(): void
// Notify
$user->notify(new PluginSubmitted($this->plugin));

Notification::route('mail', 'support@nativephp.com')
->notify(new PluginPendingReview($this->plugin));

Flux::toast(variant: 'success', text: 'Your plugin has been submitted for review!');
}

Expand Down
10 changes: 9 additions & 1 deletion app/Livewire/ShowcaseSubmissionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Livewire;

use App\Models\Showcase;
use App\Notifications\ShowcaseSubmitted;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Livewire\Attributes\Validate;
use Livewire\Component;
Expand Down Expand Up @@ -167,6 +169,9 @@ public function submit(): mixed
'approved_by' => null,
]);

Notification::route('mail', 'support@nativephp.com')
->notify(new ShowcaseSubmitted($this->showcase, resubmitted: true));

return to_route('customer.showcase.index')
->with('warning', 'Your submission has been updated and sent back for review.');
}
Expand All @@ -175,11 +180,14 @@ public function submit(): mixed
->with('success', 'Your submission has been updated.');
}

Showcase::create([
$showcase = Showcase::create([
'user_id' => auth()->id(),
...$data,
]);

Notification::route('mail', 'support@nativephp.com')
->notify(new ShowcaseSubmitted($showcase));

return to_route('customer.showcase.index')
->with('success', 'Thank you! Your app has been submitted for review.');
}
Expand Down
7 changes: 6 additions & 1 deletion app/Livewire/WallOfLoveSubmissionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Livewire;

use App\Models\WallOfLoveSubmission;
use App\Notifications\WallOfLoveSubmitted;
use Illuminate\Support\Facades\Notification;
use Livewire\Component;
use Livewire\Features\SupportFileUploads\WithFileUploads;

Expand Down Expand Up @@ -92,7 +94,7 @@ public function submit(): mixed
$photoPath = $this->photo->store('wall-of-love-photos', 'public');
}

WallOfLoveSubmission::create([
$submission = WallOfLoveSubmission::create([
'user_id' => auth()->id(),
'name' => $this->name,
'company' => $this->company ?: null,
Expand All @@ -101,6 +103,9 @@ public function submit(): mixed
'testimonial' => $this->testimonial ?: null,
]);

Notification::route('mail', 'support@nativephp.com')
->notify(new WallOfLoveSubmitted($submission));

return to_route('dashboard')->with('success', 'Thank you! Your submission has been received and is awaiting review.');
}

Expand Down
43 changes: 43 additions & 0 deletions app/Notifications/PluginPendingReview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Notifications;

use App\Filament\Resources\PluginResource;
use App\Models\Plugin;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class PluginPendingReview extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(
public Plugin $plugin
) {}

/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

public function toMail(object $notifiable): MailMessage
{
$plugin = $this->plugin->loadMissing('user');
$user = $plugin->user;

return (new MailMessage)
->subject('New Plugin Submission: '.$plugin->name)
->greeting('A plugin has been submitted for review!')
->line("**Plugin:** {$plugin->name}")
->when($plugin->display_name, fn (MailMessage $message) => $message->line("**Display name:** {$plugin->display_name}"))
->line('**Submitted by:** '.($user?->name ?? 'Unknown'))
->line('**Type:** '.$plugin->type->label())
->when($plugin->tier, fn (MailMessage $message) => $message->line('**Tier:** '.$plugin->tier->label()))
->action('Review Plugin', PluginResource::getUrl('edit', ['record' => $plugin]));
}
}
58 changes: 58 additions & 0 deletions app/Notifications/ShowcaseSubmitted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Notifications;

use App\Filament\Resources\ShowcaseResource;
use App\Models\Showcase;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;

class ShowcaseSubmitted extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(
public Showcase $showcase,
public bool $resubmitted = false,
) {}

/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

public function toMail(object $notifiable): MailMessage
{
$showcase = $this->showcase->loadMissing('user');
$user = $showcase->user;

$platforms = collect([
$showcase->has_mobile ? 'Mobile' : null,
$showcase->has_desktop ? 'Desktop' : null,
])->filter()->implode(', ');

$subject = $this->resubmitted
? 'Showcase Re-submitted for Review: '.$showcase->title
: 'New Showcase Submission: '.$showcase->title;

$greeting = $this->resubmitted
? 'An approved showcase has been updated and sent back for review.'
: 'A new app has been submitted to the Showcase!';

return (new MailMessage)
->subject($subject)
->greeting($greeting)
->line("**Title:** {$showcase->title}")
->line('**Submitted by:** '.($user?->name ?? 'Unknown'))
->when($platforms !== '', fn (MailMessage $message) => $message->line("**Platforms:** {$platforms}"))
->line('**Description:**')
->line(Str::limit($showcase->description, 500))
->action('Review Showcase', ShowcaseResource::getUrl('edit', ['record' => $showcase]));
}
}
44 changes: 44 additions & 0 deletions app/Notifications/WallOfLoveSubmitted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Notifications;

use App\Filament\Resources\WallOfLoveSubmissionResource;
use App\Models\WallOfLoveSubmission;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;

class WallOfLoveSubmitted extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(
public WallOfLoveSubmission $submission
) {}

/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

public function toMail(object $notifiable): MailMessage
{
$submission = $this->submission->loadMissing('user');
$user = $submission->user;

return (new MailMessage)
->subject('New Wall of Love Submission from '.$submission->name)
->greeting('A new Wall of Love submission has been received!')
->line("**Name:** {$submission->name}")
->line('**Submitted by:** '.($user?->name ?? 'Unknown'))
->when($submission->company, fn (MailMessage $message) => $message->line("**Company:** {$submission->company}"))
->when($submission->url, fn (MailMessage $message) => $message->line("**URL:** {$submission->url}"))
->when($submission->testimonial, fn (MailMessage $message) => $message->line('**Testimonial:**')->line(Str::limit($submission->testimonial, 500)))
->action('Review Submission', WallOfLoveSubmissionResource::getUrl('edit', ['record' => $submission]));
}
}
9 changes: 9 additions & 0 deletions tests/Feature/CustomerPluginReviewChecksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Livewire\Customer\Plugins\Show;
use App\Models\DeveloperAccount;
use App\Models\User;
use App\Notifications\PluginPendingReview;
use App\Notifications\PluginSubmitted;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
Expand Down Expand Up @@ -129,6 +130,14 @@ public function submitting_a_plugin_for_review_runs_review_checks(): void
Notification::assertSentTo($user, PluginSubmitted::class, function (PluginSubmitted $notification) use ($plugin) {
return $notification->plugin->id === $plugin->id;
});

Notification::assertSentOnDemand(
PluginPendingReview::class,
function (PluginPendingReview $notification, array $channels, object $notifiable) use ($plugin) {
return $notifiable->routes['mail'] === 'support@nativephp.com'
&& $notification->plugin->id === $plugin->id;
}
);
}

/** @test */
Expand Down
Loading
Loading