1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Services/Recurring/GetInvoicePdf.php
2024-01-14 15:05:00 +11:00

40 lines
994 B
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Recurring;
use App\Jobs\Entity\CreateRawPdf;
use App\Models\ClientContact;
use App\Services\AbstractService;
class GetInvoicePdf extends AbstractService
{
public function __construct(public $entity, public ?ClientContact $contact = null)
{
}
public function run()
{
if (! $this->contact) {
$this->contact = $this->entity->client->primary_contact()->first();
}
$invitation = $this->entity->invitations->where('client_contact_id', $this->contact->id)->first();
if (! $invitation) {
$invitation = $this->entity->invitations->first();
}
return (new CreateRawPdf($invitation))->handle();
}
}