MentalityDrillCategory.php 958 B

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 $casts = ['banner'=>'array'];
  20. public function getPicAttribute()
  21. {
  22. return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL;
  23. }
  24. public function getIndexPicAttribute()
  25. {
  26. return isset($this->attributes['index_pic']) ? config('console.pic_path').$this->attributes['index_pic'] : NULL;
  27. }
  28. public function mentalityDrill(){
  29. return $this->hasMany(MentalityDrill::class, 'category_id', 'id');
  30. }
  31. }