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; } }