- Add new TransmittalPDFExportJob to generate PDFs using dompdf - Remove old Excel export implementation (TransmittalsExport) - Update ExportCompleteJob to use new PDF job instead of Excel - Add TestQueueJob for queue testing with new route - Update notification label from "Download File" to "Download PDF File" - Fix auth() helper usage by importing Auth facade consistently
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\Forms\Components\Actions;
|
|
use Filament\Notifications\Livewire\Notifications;
|
|
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());
|
|
|
|
Notifications::make()
|
|
->success()
|
|
->title('Export Completed')
|
|
->actions([
|
|
Actions\Action::make('download_transmittal-export.pdf')
|
|
->label('Download PDF File')
|
|
->url(Storage::url('transmittal-export.pdf'), true)
|
|
->markAsRead(),
|
|
])
|
|
->sendToDatabase($this->user);
|
|
}
|
|
}
|