1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

INA-5 | Add service | append linked job

This commit is contained in:
Nikola Cirkovic 2022-05-23 01:08:08 +02:00
parent 5a6f4801ce
commit 89373701c9

View File

@ -11,6 +11,7 @@
namespace App\Models;
use App\Services\TaskScheduler\TaskSchedulerService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@ -32,12 +33,27 @@ class Scheduler extends Model
'repeat_every',
'scheduled_run',
];
protected $appends = ['linked_job'];
const DAILY = 'DAY';
const WEEKLY = 'WEEK';
const MONTHLY = 'MONTH';
const QUARTERLY = '3MONTHS';
const ANNUALLY = 'YEAR';
public function getLinkedJobAttribute()
{
return $this->job ?? [];
}
/**
* Service entry points.
*/
public function service(): TaskSchedulerService
{
return new TaskSchedulerService($this);
}
public function job(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(ScheduledJob::class, 'scheduler_id', 'id');