Deploy Ladill Hosting / deploy (push) Successful in 31s
Stop emailing users when their servers hit usage limits; keep database notifications for the in-app bell. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\HostingAccount;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class HostingResourceWarningNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
private readonly HostingAccount $account,
|
|
private readonly string $subjectLine,
|
|
private readonly string $messageBody
|
|
) {
|
|
}
|
|
|
|
public function via($notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function toMail($notifiable): MailMessage
|
|
{
|
|
return (new MailMessage())
|
|
->subject($this->subjectLine)
|
|
->greeting('Hosting resource update')
|
|
->line($this->messageBody)
|
|
->line('Domain: ' . ($this->account->primary_domain ?: $this->account->username))
|
|
->line('Resource state: ' . ucfirst((string) ($this->account->resource_status ?: 'active')))
|
|
->action('Manage Hosting', route('hosting.accounts.show', $this->account));
|
|
}
|
|
|
|
public function toArray($notifiable): array
|
|
{
|
|
return [
|
|
'title' => $this->subjectLine,
|
|
'message' => $this->messageBody,
|
|
'icon' => 'hosting',
|
|
'url' => route('hosting.accounts.show', $this->account),
|
|
];
|
|
}
|
|
}
|