123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Models;
- class MentalityDrillCategory extends SoftBaseModel
- {
- //是否投放首页
- const isIndexYes = 1;
- const isIndexNo = 0;
- //是否开启课程
- const isSubjectYes = 1;
- const isSubjectNo = 0;
- const isSubjectMap = array(
- self::isSubjectYes => "是",
- self::isSubjectNo => "否"
- );
- const isIndexMap = array(
- self::isIndexYes => "是",
- self::isIndexNo => "否"
- );
- protected $fillable = ['name','pid','rank','is_index','is_subject','pic','index_pic','index_info'];
- protected $casts = ['banner'=>'array'];
- public function getPicAttribute()
- {
- return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL;
- }
- public function getIndexPicAttribute()
- {
- return isset($this->attributes['index_pic']) ? config('console.pic_path').$this->attributes['index_pic'] : NULL;
- }
- public function mentalityDrill(){
- return $this->hasMany(MentalityDrill::class, 'category_id', 'id');
- }
- }
|