MentalityDrillExtend.php 1011 B

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