55 lines
1.9 KiB
PHP
55 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Estimate;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class EstimateNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
private Estimate $estimate
|
|
) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$jobCard = $this->estimate->jobCard;
|
|
$portalUrl = route('customer-portal.estimate', [
|
|
'jobCard' => $jobCard->id,
|
|
'estimate' => $this->estimate->id
|
|
]);
|
|
|
|
return (new MailMessage)
|
|
->subject("Repair Estimate Ready - Job #{$jobCard->job_number}")
|
|
->greeting("Hello {$notifiable->name},")
|
|
->line("Your vehicle repair estimate is ready for review.")
|
|
->line("**Vehicle:** {$jobCard->vehicle->year} {$jobCard->vehicle->make} {$jobCard->vehicle->model}")
|
|
->line("**Job Number:** {$jobCard->job_number}")
|
|
->line("**Estimate Total:** $" . number_format($this->estimate->total_amount, 2))
|
|
->action('View Estimate', $portalUrl)
|
|
->line('Please review and approve the estimate to proceed with repairs.')
|
|
->line('If you have any questions, please contact us at your earliest convenience.')
|
|
->salutation('Best regards,')
|
|
->salutation('Your Service Team');
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'estimate_id' => $this->estimate->id,
|
|
'job_card_id' => $this->estimate->job_card_id,
|
|
'estimate_number' => $this->estimate->estimate_number,
|
|
'total_amount' => $this->estimate->total_amount,
|
|
];
|
|
}
|
|
} |