12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace catchAdmin\transport\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use think\facade\Db;
- class StuckSection extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'stuck_section';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 名称
- 'name',
- // 前置卡点
- 'pre_spot',
- // 后置卡点
- 'pos_spot',
- // 区间长度
- 'distance',
- // 最大限速(km/h)
- 'max_speed',
- // 启用逆行状态
- 'retrograde_stat',
- // 启用超速状态
- 'over_speed_stat',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 列表
- */
- public function getList()
- {
- $res=$this->dataRange()
- ->catchSearch()
- ->append(['pos_spot_text','pre_spot_text'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- return $res;
- }
- //根据name搜索
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%' . $value . '%');
- }
- public function getPosSpotTextAttr($value){
- $value=$this->getData('pos_spot');
- return Db::table('stuck_point')->where('id',$value)->value('name');
- }
- public function getPreSpotTextAttr($value){
- $value=$this->getData('pre_spot');
- return Db::table('stuck_point')->where('id',$value)->value('name');
- }
- public function getRetrogradeStatAttr($value){
- return $value?true:false;
- }
- public function getOverSpeedStatAttr($value){
- return $value?true:false;
- }
- public function getPreSpotAttr($value){
- return (string)$value;
- }
- public function getPosSpotAttr($value){
- return (string)$value;
- }
- public function getDistanceAttr($value){
- return (string)$value;
- }
- public function getMaxSpeedAttr($value){
- return (string)$value;
- }
- }
|