1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Services/Credit/GetCreditPdf.php

51 lines
1.3 KiB
PHP
Raw Normal View History

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