File: //var/www/quadcode/app/Models/AbstractQueue.php
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $data
* @property int $status
* @property string $error
* @property string $lead_id
* @property string $lead_created_at
* @property string $created_at
* @property string $updated_at
*/
abstract class AbstractQueue extends Model
{
const STATUS_NEW = 0;
const STATUS_IN_PROGRESS = 1;
const STATUS_DONE = 2;
const STATUS_ERROR = 3;
const STATUS_CANCEL = 4;
protected $fillable = [
'data',
'status',
'error',
'lead_id',
'lead_created_at',
];
public function inProgress(): void
{
$this->update(['status' => self::STATUS_IN_PROGRESS]);
}
public function error(?string $message = null): void
{
$this->status = self::STATUS_ERROR;
if (!empty($message)) {
$this->error = $message;
}
$this->save();
}
public function done(): void
{
$this->lead_created_at = Carbon::now();
$this->status = self::STATUS_DONE;
$this->error = null;
$this->save();
}
}