Support downloading PDF through the API
This commit is contained in:
parent
b0f8385a25
commit
78bafbbf09
2 changed files with 14 additions and 0 deletions
|
|
@ -358,4 +358,17 @@ class InvoiceApiController extends BaseAPIController
|
|||
return $this->itemResponse($invoice);
|
||||
}
|
||||
|
||||
public function download(InvoiceRequest $request)
|
||||
{
|
||||
$invoice = $request->entity();
|
||||
$pdfString = $invoice->getPDFString();
|
||||
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Length: ' . strlen($pdfString));
|
||||
header('Content-disposition: attachment; filename="' . $invoice->getFileName() . '"');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
return $pdfString;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
|||
//Route::get('quotes', 'QuoteApiController@index');
|
||||
//Route::resource('quotes', 'QuoteApiController');
|
||||
Route::get('invoices', 'InvoiceApiController@index');
|
||||
Route::get('download/{invoice_id}', 'InvoiceApiController@download');
|
||||
Route::resource('invoices', 'InvoiceApiController');
|
||||
Route::get('payments', 'PaymentApiController@index');
|
||||
Route::resource('payments', 'PaymentApiController');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue