invoiceninja/app/Services/Invoice/GetInvoicePdf.php
David Bomba 4a3d37a42b
Flutter Client ! (#3325)
* Working on emailing invoices

* Working on emailing and displaying email

* Working on emailing and displaying email

* Email invoices

* Fixes for html emails

* Restart queue after self-update

* Email Invoices

* Push Flutter Web Clientgit statusgit status!
2020-02-13 22:27:42 +11:00

49 lines
958 B
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\Invoice;
use App\Jobs\Invoice\CreateInvoicePdf;
use Illuminate\Support\Facades\Storage;
class GetInvoicePdf
{
public function __invoke($invoice, $contact = null)
{
if(!$contact)
$contact = $invoice->client->primary_contact()->first();
$path = $invoice->client->client_hash . '/invoices/';
$file_path = $path . $invoice->number . '.pdf';
$disk = config('filesystems.default');
$file = Storage::disk($disk)->exists($file_path);
if(!$file)
{
$file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact);
}
//return $file_path;
return Storage::disk($disk)->path($file_path);
}
}