setParentColumn('pid'); $this->setOrderColumn('rank'); $this->setTitleColumn('name'); } /** * 所有一级 * @var integer */ const PID_0 = 0; /** * 是否显示 0:不显示 * @var integer */ const IS_SHOW_0 = 0; /** * 是否显示 1:显示 * @var integer */ const IS_SHOW_1 = 1; static public $isShowMap = [ self::IS_SHOW_0 => '不显示', self::IS_SHOW_1 => '显示' ]; protected $casts = ['banner'=>'json']; public function tags(){ return $this->hasMany(SpecialistCloumnTag::class, 'specialist_cloumn_id', 'id'); } public function getPicAttribute() { return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL; } public function getBannerAttribute($value) { return array_values(json_decode($value, true) ?: []); } public function setBannerAttribute($value) { $this->attributes['banner'] = json_encode(array_values($value)); } }