MentalityDrillsSubject.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Models;
  3. class MentalityDrillsSubject extends SoftBaseModel
  4. {
  5. protected $table = "mentality_drill_subject";
  6. /**
  7. * 类别 1:音频
  8. * @var integer
  9. */
  10. const TYPE_1 = 1;
  11. /**
  12. * 类别 2:视频
  13. * @var integer
  14. */
  15. const TYPE_2 = 2;
  16. static public $typeMap = [
  17. // self::TYPE_1 => '音频',
  18. self::TYPE_2 => '视频',
  19. ];
  20. protected $appends = ['second'];
  21. public function getSrcAttribute()
  22. {
  23. return isset($this->attributes['src']) ? config('console.pic_path').$this->attributes['src'] : NULL;
  24. }
  25. public function getPicAttribute()
  26. {
  27. return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL;
  28. }
  29. public function getSecondAttribute()
  30. {
  31. if (strstr($this->attributes['time'],":")){
  32. $timeArr = explode(':', $this->attributes['time']);
  33. return $timeArr[0]*60 + $timeArr[1];
  34. }else{
  35. return $this->attributes['time'];
  36. }
  37. }
  38. }