6
0
Fork 0
jiqu-library-server/app/Models/Store/DeviceRecord.php

52 lines
1.1 KiB
PHP

<?php
namespace App\Models\Store;
use Illuminate\Database\Eloquent\Model;
use Dcat\Admin\Traits\HasDateTimeFormatter;
class DeviceRecord extends Model
{
use HasDateTimeFormatter;
public const STATUS_PROCESSING = 0;
public const STATUS_SUCCESS = 1;
public const STATUS_FAIL = 2;
protected $table = 'store_device_records';
protected $fillable = ['data', 'device_id', 'result', 'resource_id', 'resource_type', 'status', 'store_id'];
protected $casts = [
'result' => 'json',
'data' => 'json',
];
public static $statusMap = [
self::STATUS_PROCESSING => '处理中',
self::STATUS_SUCCESS => '成功',
self::STATUS_FAIL => '失败',
];
public static $statusColor = [
self::STATUS_PROCESSING => 'primary',
self::STATUS_SUCCESS => 'success',
self::STATUS_FAIL => 'danger',
];
public function device()
{
return $this->belongsTo(Device::class, 'device_id');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function resource()
{
return $this->morphTo();
}
}