I'm using laravel-dompdf to generate PDF reports for my app. I had used this in the same app and it's working fine... what whit this model it's generating a blank PDF.
The query is returning data, so that isn't the problem... my code:
public function serviceReport(Request $request){
$title = 'Servicio';
$meta = [
'N°' => '1'
];
$query = Service::query();
$query->select(\DB::raw('services.id as serviceid'), \DB::raw('customers.name as customername'))
->leftJoin('customers', 'customers.id', '=', 'services.id_customers')
->where('services.id', '=', '1')
->get();
$columns = [
'Servicio' => 'serviceid',
'Cliente' => 'customername'
];
return PdfReport::of($title, $meta, $query, $columns)
->limit(20)
->download('filename');
}
my vuejs function:
getReport(){
var name = 'Reporte Servicio.pdf';
this.service.post('/api/service/report', {responseType: 'blob'})
.then((response) => {
var fileURL = window.URL.createObjectURL(new Blob([response.data]));
var fileLink = document.createElement('a');
fileLink.href = fileURL;
fileLink.setAttribute('download', name);
document.body.appendChild(fileLink);
fileLink.click();
})
.catch(function (error) {
console.log(error);
})
},
PDF:
The problem is vForm. I have changed to a normal axios request and started to work.