get invoice from url

This commit is contained in:
Peter Papp
2021-04-27 08:57:00 +02:00
parent 5be490c8d5
commit f7135c9b27
8 changed files with 175 additions and 43 deletions

View File

@@ -16,6 +16,7 @@ use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Str;
use Storage;
class InvoiceController extends Controller
{
@@ -39,6 +40,19 @@ class InvoiceController extends Controller
);
}
/**
* @param Invoice $invoice
* @return \Symfony\Component\HttpFoundation\StreamedResponse
*/
public function get_invoice(Invoice $invoice)
{
if (! Storage::exists(invoice_path($invoice))) {
abort(404, 'Not Found');
}
return Storage::download(invoice_path($invoice), "invoice-{$invoice->id}.pdf");
}
/**
* @return mixed
*/