-
app/Jobs/GenerateInvoicePdfJob.php
Open in GitHubclass GenerateInvoicePdfJob { // public function __construct($invoice, $deleteExistingFile = false) { $this->invoice = $invoice; $this->deleteExistingFile = $deleteExistingFile; } public function handle() { $this->invoice->generatePDF('invoice', $this->invoice->invoice_number, $this->deleteExistingFile); return 0; } }
-
app/Http/Controllers/V1/Invoice/InvoicesController.php
Open in GitHubuse Crater\Http\Controllers\Controller; use Crater\Http\Requests; use Crater\Models\Invoice; use Crater\Jobs\GenerateInvoicePdfJob; class InvoicesController extends Controller { // public function store(Requests\InvoicesRequest $request) { $invoice = Invoice::createInvoice($request); if ($request->has('invoiceSend')) { $invoice->send($request->subject, $request->body); } GenerateInvoicePdfJob::dispatch($invoice); return response()->json([ 'invoice' => $invoice, ]); } // }