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

39 lines
877 B
PHP
Raw Normal View History

2023-03-21 22:00:45 +01:00
<?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 App\Utils\Traits\MakesHash;
2023-10-26 04:57:44 +02:00
use Illuminate\Support\Str;
2023-03-21 22:00:45 +01:00
class EmailRecord
{
use MakesHash;
public function __construct(public Scheduler $scheduler)
{
}
public function run()
{
$class = 'App\\Models\\' . Str::camel($this->scheduler->parameters['entity']);
2023-04-14 05:04:28 +02:00
$entity = $class::find($this->decodePrimaryKey($this->scheduler->parameters['entity_id']));
2024-01-14 05:05:00 +01:00
2023-10-26 04:57:44 +02:00
if($entity) {
2024-01-03 12:10:02 +01:00
$entity->service()->markSent()->sendEmail();
2023-10-26 04:57:44 +02:00
}
2023-03-21 22:00:45 +01:00
$this->scheduler->forceDelete();
}
}