MentalityDrillCategory.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. class MentalityDrillCategory extends SoftBaseModel
  4. {
  5. //是否投放首页
  6. const isIndexYes = 1;
  7. const isIndexNo = 0;
  8. //是否开启课程
  9. const isSubjectYes = 1;
  10. const isSubjectNo = 0;
  11. const isSubjectMap = array(
  12. self::isSubjectYes => "是",
  13. self::isSubjectNo => "否"
  14. );
  15. const isIndexMap = array(
  16. self::isIndexYes => "是",
  17. self::isIndexNo => "否"
  18. );
  19. protected $fillable = ['name','pid','rank','is_index','is_subject','pic','index_pic','index_info'];
  20. protected $casts = ['banner'=>'array'];
  21. public function getPicAttribute()
  22. {
  23. return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL;
  24. }
  25. public function getIndexPicAttribute()
  26. {
  27. return isset($this->attributes['index_pic']) ? config('console.pic_path').$this->attributes['index_pic'] : NULL;
  28. }
  29. public function mentalityDrill(){
  30. return $this->hasMany(MentalityDrill::class, 'category_id', 'id');
  31. }
  32. }