2
I have a problem in the Windows when mounting a PDF. It gives the output all in binary. I am https://github.com/barryvdh/laravel-dompdf
Look at the code:
public function relatorio($id)
{
$pedidos_id = Pedidos::find($id);
$pedidos['pedidos'] = Pedidos::select(
'pedidos_id',
'cliente_id',
'pedidos.observacao',
'pedidos.especificacoes',
'pedidos.frete',
'pedidos.data',
'pedidos.numero_pedido',
'pedidos.preco_ipi',
'clientes.nome as nome_cliente',
'clientes.endereco as endereco_cliente',
'clientes.telefone as telefone_cliente',
'clientes.email as email_cliente',
'clientes.uf as estado_cliente',
'fornecedores.nome as nome_fornecedor',
'pedidos.total_m2',
'pedidos.total_m3',
'pedidos.total'
)
->join('clientes','clientes_id', '=', 'cliente_id')
->join('fornecedores','fornecedores_id', '=', 'fornecedor_id')
->orderBy('pedidos.data')
->where('pedidos_id',$pedidos_id)->get();
// dados do pedido
if(!$pedidos)
{
return response()->json([
'message' => 'Nenhum pedido encontrado',
], 404);
}
$pdf = PDF::loadView('pedidos', $pedidos);
return $pdf->download('relatorio.pdf');
}
EXIT
Actually this is the pdf even if you open it in the notepad for example, but have tried using the
$pdf->stream();
to see what comes out instead of the download? Your view requests exists and is correct?– Darlei Fernando Zillmer
Is it not the route that is wrong? It looks like this: Route::get('return_report/{pedidos_id}','Pedidoscontroller@report');
– Felipe Michael da Fonseca
It shouldn’t, if it was on the route the page wouldn’t load, but try to leave the route like this and use the stream to test, what you can also try is to post instead of get. The pdf load is being done, it’s just not downloading (this may be because of get, but I’m not sure, I would have to test)
– Darlei Fernando Zillmer
Where exactly is this route called? the problem is before!
– novic
@Virgilionovic did the report but it comes out php programming. see image above
– Felipe Michael da Fonseca
So it has extra code (not required)
$pedidos_id = Pedidos::find($id);
this line for example draws off no need, can already bring the data only with the bottom if return blz if there are no problems somewhere, your route has the variablepedidos_id
, then the method formula follows the same namerelatorio($pedidos_id)
, try these changes– novic