41 lines
781 B
PHP
41 lines
781 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use Illuminate\View\View;
|
||
|
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
|
||
|
|
||
|
use App\Models\Invoice;
|
||
|
|
||
|
/**
|
||
|
* Class InvoiceController
|
||
|
* This controller manages invoices
|
||
|
*
|
||
|
* The methods to this controller should be projected by the route
|
||
|
*
|
||
|
* @package App\Http\Controllers
|
||
|
*/
|
||
|
class InvoiceController extends Controller
|
||
|
{
|
||
|
/**
|
||
|
* Return the invoice in PDF format, ready to download
|
||
|
*
|
||
|
* @param Invoice $o
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function pdf(Invoice $o)
|
||
|
{
|
||
|
return PDF::loadView('u.invoice.home',['o'=>$o])->stream(sprintf('%s.pdf',$o->sid));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Render a specific invoice for the user
|
||
|
*
|
||
|
* @param Invoice $o
|
||
|
* @return View
|
||
|
*/
|
||
|
public function view(Invoice $o): View
|
||
|
{
|
||
|
return View('invoice.view',['o'=>$o]);
|
||
|
}
|
||
|
}
|