The notification was using the wrong class (Notifications instead of Notification). This caused the export completion notification to fail. Updated the import and instantiation to use the correct Filament Notification class.
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Transmittal;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Notifications\Actions\Action;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class TransmittalPDFExportJob implements ShouldQueue
|
|
{
|
|
use Queueable, Dispatchable, InteractsWithQueue, SerializesModels;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(private $user, private array $ids)
|
|
{}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$transmittals = Transmittal::query()
|
|
->with(['client', 'branch', 'files.notes', 'files.remarks'])
|
|
->whereIn('id', $this->ids)
|
|
->get();
|
|
|
|
$pdf = Pdf::loadView('transmittal.export.transmittal-export-pdf', [
|
|
'transmittals' => $transmittals,
|
|
]);
|
|
|
|
Storage::disk('public')->put('transmittal-export.pdf', $pdf->output());
|
|
|
|
Notification::make()
|
|
->success()
|
|
->title('Export Completed')
|
|
->actions([
|
|
Action::make('download_transmittal-export.pdf')
|
|
->label('Download PDF File')
|
|
->url(Storage::url('transmittal-export.pdf'), true)
|
|
->markAsRead(),
|
|
])
|
|
->sendToDatabase($this->user);
|
|
}
|
|
}
|