-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathBundlePluginAdded.php
More file actions
57 lines (48 loc) · 1.61 KB
/
BundlePluginAdded.php
File metadata and controls
57 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace App\Notifications;
use App\Models\Plugin;
use App\Models\PluginBundle;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class BundlePluginAdded extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public Plugin $plugin,
public PluginBundle $bundle,
) {}
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$parts = explode('/', $this->plugin->name ?? '');
$vendor = $parts[0] ?? '';
$package = $parts[1] ?? '';
$pluginUrl = "https://nativephp.com/plugins/{$vendor}/{$package}";
return (new MailMessage)
->subject("New plugin added to your {$this->bundle->name} bundle!")
->greeting('Great news!')
->line("We've added **{$this->plugin->name}** to the **{$this->bundle->name}** bundle — and because you already own the bundle, it's yours for free.")
->action('Check it out', $pluginUrl)
->line('Thank you for being a NativePHP customer!');
}
/**
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'plugin_id' => $this->plugin->id,
'plugin_name' => $this->plugin->name,
'bundle_id' => $this->bundle->id,
'bundle_name' => $this->bundle->name,
];
}
}