mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
* style cs * Style CS * Throw Record not found exception if invalid primary key hash is provided * Improve error handling * Create abstract implementation for designs * working on custom designs * Add Design Model * invoice services * Download Invoice by Invitation
53 lines
1005 B
PHP
53 lines
1005 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 __construct()
|
|
{
|
|
}
|
|
|
|
public function __invoke($invoice, $contact = null)
|
|
{
|
|
|
|
$path = $invoice->client->client_hash . '/invoices/';
|
|
|
|
$file_path = $path . $invoice->number . '.pdf';
|
|
|
|
$disk = config('filesystems.default');
|
|
|
|
$file = Storage::disk($disk)->exists($file_path);
|
|
|
|
if(!$contact)
|
|
$contact = $invoice->client->primary_contact()->first();
|
|
|
|
if(!$file)
|
|
{
|
|
|
|
$file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact);
|
|
|
|
}
|
|
|
|
//return $file_path;
|
|
|
|
return Storage::disk($disk)->path($file_path);
|
|
|
|
}
|
|
|
|
}
|
|
|