mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
a79c7bf60d
* Working on emailing invoices * Working on emailing and displaying email * Working on emailing and displaying email * Email invoices * Fixes for html emails * Ensure valid client prior to store * Ensure client exists when storing an entity * refactor for emails * Design Transformer * Include designs in first_load response * Code cleanup
49 lines
943 B
PHP
49 lines
943 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 run($invoice, $contact = null)
|
|
{
|
|
|
|
if(!$contact)
|
|
$contact = $invoice->client->primary_contact()->first();
|
|
|
|
$path = $invoice->client->invoice_filepath();
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|