123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Models;
- use Encore\Admin\Traits\ModelTree;
- use Encore\Admin\Traits\AdminBuilder;
- class SpecialistCloumn extends SoftBaseModel
- {
- use ModelTree, AdminBuilder;
-
- public function __construct(array $attributes = [])
- {
- parent::__construct($attributes);
-
- $this->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));
- }
- }
|