Rename ScheduleEntity -> EmailRecord

This commit is contained in:
David Bomba 2023-03-22 08:00:45 +11:00
parent 8fff97ac4b
commit 915a99fd56
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?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\DataMapper\Schedule;
class EmailRecord
{
/**
* Defines the template name
*
* @var string
*/
public string $template = 'email_record';
/**
* Defines the template name
*
* @var string
*/
public string $entity = ''; // invoice, credit, quote, purchase_order
/**
* Defines the template name
*
* @var string
*/
public string $entity_id = '';
}

View File

@ -0,0 +1,34 @@
<?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\Scheduler;
use App\Models\Scheduler;
use Illuminate\Support\Str;
use App\Utils\Traits\MakesHash;
class EmailRecord
{
use MakesHash;
public function __construct(public Scheduler $scheduler)
{
}
public function run()
{
$class = 'App\\Models\\' . Str::camel($this->scheduler->parameters['entity']);
$class::find($this->decodePrimaryKey($this->scheduler->parameters['entity_id']))->service()->sendEmail();
$this->scheduler->forceDelete();
}
}