mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 00:02:15 +00:00
pdf invoice generation scaffolding
This commit is contained in:
@@ -66,20 +66,16 @@ class InvoiceController extends Controller
|
||||
$client = $this->getOrStoreClient($request);
|
||||
|
||||
$invoice = Invoice::create([
|
||||
'user_id' => $request->user()->id,
|
||||
'client_id' => $client->id ?? null,
|
||||
|
||||
'invoice_type' => $request->invoice_type,
|
||||
'invoice_number' => $request->invoice_number,
|
||||
|
||||
'user_id' => $request->user()->id,
|
||||
'client_id' => $client->id ?? null,
|
||||
'invoice_type' => $request->invoice_type,
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'variable_number' => $request->variable_number,
|
||||
'delivery_at' => $request->delivery_at,
|
||||
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => $request->items,
|
||||
|
||||
'client' => [
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => $request->items,
|
||||
'client' => [
|
||||
'email' => $client->email ?? $request->client_email,
|
||||
'name' => $client->name ?? $request->client_name,
|
||||
'address' => $client->address ?? $request->client_address,
|
||||
@@ -92,14 +88,18 @@ class InvoiceController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
// Generate PDF
|
||||
\PDF::loadView('oasis.invoices.invoice', [
|
||||
'invoice' => Invoice::find($invoice->id),
|
||||
'user' => $request->user(),
|
||||
])
|
||||
->save(storage_path() . "/app/faktura-{$invoice->id}.pdf");
|
||||
->setPaper('a4')
|
||||
->setOrientation('portrait')
|
||||
->save(
|
||||
storage_path("/app/files/{$request->user()->id}/invoice-{$invoice->id}.pdf")
|
||||
);
|
||||
|
||||
if ($request->send_invoice && $invoice->client['email']) {
|
||||
|
||||
Notification::route('mail', $invoice->client['email'])
|
||||
->notify(new InvoiceDeliveryNotification($request->user()));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,32 @@
|
||||
|
||||
use Laravel\Cashier\Cashier;
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return bool
|
||||
*/
|
||||
function is_route($name)
|
||||
{
|
||||
return Route::currentRouteName() === $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filepath
|
||||
* @return string
|
||||
*/
|
||||
function get_storage_path($filepath)
|
||||
{
|
||||
if (is_null($filepath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::exists($filepath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'data:' . Storage::mimeType($filepath) . ';base64,' . base64_encode(Storage::get($filepath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get only tax for single invoice item
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user