-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathNewPluginAvailable.php
More file actions
55 lines (47 loc) · 1.67 KB
/
NewPluginAvailable.php
File metadata and controls
55 lines (47 loc) · 1.67 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
<?php
namespace App\Notifications;
use App\Models\Plugin;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewPluginAvailable extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public Plugin $plugin
) {}
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
if (! $notifiable->receives_new_plugin_notifications) {
return [];
}
return ['mail', 'database'];
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject("New Plugin: {$this->plugin->name}")
->greeting('A new plugin is available!')
->line("**{$this->plugin->name}** has just been added to the NativePHP Plugin Marketplace.")
->action('View Plugin', route('plugins.show', $this->plugin->routeParams()))
->line('[Manage your notification preferences]('.route('customer.settings', ['tab' => 'notifications']).').');
}
/**
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'title' => "New Plugin: {$this->plugin->name}",
'body' => "{$this->plugin->name} has just been added to the NativePHP Plugin Marketplace.",
'plugin_id' => $this->plugin->id,
'plugin_name' => $this->plugin->name,
'action_url' => route('plugins.show', $this->plugin->routeParams()),
'action_label' => 'View Plugin',
];
}
}