You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class LanzuServiceSpeaker extends Model{ use HasDateTimeFormatter; protected $table = 'lanzu_service_speakers'; protected $dateFormat = 'U';
public function store(){ return $this->hasOne('\App\Models\v3\Store','id','store_id'); }
public static $_STATE = [ 0=>'离线', 1=>'在线']; public static $_IS_BIND = [ 0=>'未绑定', 1=>'已绑定']; /* 添加转换字段 */ protected $appends = [ 'created_at_text', 'updated_at_text', 'bind_time_text', 'is_bind_text', 'state_text' ]; public function getStateTextAttribute() { $value = $this->status; return isset(self::$_STATE[$value])?self::$_STATE[$value]:''; } public function getIsBindTextAttribute() { $value = $this->is_bind; return isset(self::$_IS_BIND[$value])?self::$_IS_BIND[$value]:''; } public function getCreatedAtTextAttribute() { $value = $this->created_at; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getUpdatedAtTextAttribute() { $value = $this->updated_at; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getBindTimeTextAttribute() { $value = $this->bind_time; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; }}
|