69 lines
1.4 KiB
PHP
69 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* AVSDev UF Worker (https://avsdev.uk)
|
|
*
|
|
* @link https://git.avsdev.uk/avsdev/sprinkle-worker
|
|
* @license https://git.avsdev.uk/avsdev/sprinkle-worker/blob/master/LICENSE.md (LGPL-3.0 License)
|
|
*/
|
|
|
|
namespace UserFrosting\Sprinkle\Worker\Database\Models;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Capsule\Manager as DB;
|
|
use UserFrosting\Sprinkle\Core\Database\Models\Model;
|
|
|
|
/**
|
|
* Queued Job class
|
|
*
|
|
* @author Craig Williams (https://avsdev.uk)
|
|
*/
|
|
class QueuedJob extends Model
|
|
{
|
|
/**
|
|
* @var string The name of the table for the current model.
|
|
*/
|
|
protected $table = 'queued_jobs';
|
|
|
|
/**
|
|
* Fields that should be mass-assignable when creating a new Organisation.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = [
|
|
'job',
|
|
'params',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $dates = [
|
|
'created_at',
|
|
'updated_at',
|
|
'started_at',
|
|
'completed_at',
|
|
];
|
|
|
|
/**
|
|
* @var bool Enable timestamps for this class.
|
|
*/
|
|
public $timestamps = true;
|
|
|
|
|
|
/**
|
|
* Dequeues the current model as a job object
|
|
*/
|
|
public function dequeue()
|
|
{
|
|
$jobClass = $this->job;
|
|
$params = json_decode($this->params, true);
|
|
|
|
$job = new $jobClass();
|
|
$job->setParams($params);
|
|
return $job;
|
|
}
|
|
}
|