invoiceninja/app/Services/Credit/GetCreditPdf.php

54 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2020-07-01 11:06:40 +10:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-07-01 11:06:40 +10:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-07-01 11:06:40 +10:00
*
2021-06-16 16:58:16 +10:00
* @license https://www.elastic.co/licensing/elastic-license
2020-07-01 11:06:40 +10:00
*/
namespace App\Services\Credit;
2020-10-26 15:06:58 +11:00
use App\Jobs\Entity\CreateEntityPdf;
use App\Services\AbstractService;
2021-04-06 22:36:50 +10:00
use App\Utils\TempFile;
use Illuminate\Support\Facades\Storage;
class GetCreditPdf extends AbstractService
{
2020-11-11 11:13:39 +11:00
public $credit;
2020-02-19 07:56:21 +11:00
2020-11-11 11:13:39 +11:00
public $contact;
2020-02-19 07:56:21 +11:00
2020-11-11 11:13:39 +11:00
public $invitation;
public function __construct($invitation)
{
2020-11-11 11:13:39 +11:00
$this->invitation = $invitation;
$this->credit = $invitation->credit;
$this->contact = $invitation->contact;
}
2020-02-19 07:56:21 +11:00
public function run()
{
if (! $this->contact) {
2020-02-19 07:56:21 +11:00
$this->contact = $this->credit->client->primary_contact()->first();
}
2021-06-12 21:50:01 +10:00
$path = $this->credit->client->credit_filepath($this->invitation);
$file_path = $path.$this->credit->numberFormatter().'.pdf';
2021-07-07 21:39:49 +10:00
// $disk = 'public';
$disk = config('filesystems.default');
2021-05-15 12:31:17 +10:00
$file_path = CreateEntityPdf::dispatchNow($this->invitation);
2021-04-06 22:36:50 +10:00
2021-07-07 21:39:49 +10:00
nlog($file_path);
return $file_path;
// return Storage::disk($disk)->path($file_path);
}
}