Is there an option to overwrite the existing PDF file?
I have this function:
public function quote($id){
$quote = Quotes::find($id);
$last_quote = sprintf("%'.04d\n", $quote->quote_number);
$customer = Customer::find($quote->customer_id);
$items = $quote->Items()->get();
$fullinfo = json_decode($quote->fullinfo);
$token = $quote->Tokens()->first();
$data = [
'quote' => $quote,
'last_quote' => $last_quote,
'customer' => $customer,
'items' => $items,
'fullinfo' => $fullinfo,
'token' => $token,
];
$pdf = App::make('snappy.pdf.wrapper');
$pdf->LoadView('quotes.quote_print', $data)
->setOption('page-size', 'A4');
$path = storage_path() . "/quotes/{$customer->name}/cotizacion.pdf";
$pdf->save($path);
return $pdf->stream();
}
The problem is that when i run that function for the second time i get a file already exist error.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire