1
0
Fork 0
internet-everythings-agricu.../app/Models/WarningNotice.php

52 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;
class WarningNotice extends Model
{
use Filterable;
protected $fillable = [
'device_id', 'lv', 'content', 'status', 'remarks',
'reported_at',
];
public static function lvMap(){
return [
'1' => 'Ⅰ级预警',
'2' => 'Ⅱ级预警',
'3' => 'Ⅲ级预警',
'4' => 'Ⅳ级预警',
];
}
public static function stateMap(){
return [
'0'=>'未处理',
'1'=>'已处理',
'2'=>'已忽略'
];
}
public static function stateMapLabel()
{
return [
'0' => "<span class='label label-danger'>未处理</span>",
'1'=> "<span class='label label-info'>已处理</span>",
'2' => "<span class='label label-warning'>已忽略</span>",
'*'=>'其他:${status}'
];
}
public function loggable(){
return $this->morphTo();
}
public function device(){
return $this->belongsTo(Device::class, 'device_id');
}
}