mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
* Change '__invoke' to 'run' for Invoice services * Change '__invoke' to 'run' for Quote services
49 lines
951 B
PHP
49 lines
951 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->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);
|
|
|
|
}
|
|
|
|
}
|
|
|