12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Models;
- class MentalityDrillsSubject extends SoftBaseModel
- {
- protected $table = "mentality_drill_subject";
- /**
- * 类别 1:音频
- * @var integer
- */
- const TYPE_1 = 1;
- /**
- * 类别 2:视频
- * @var integer
- */
- const TYPE_2 = 2;
- static public $typeMap = [
- // self::TYPE_1 => '音频',
- self::TYPE_2 => '视频',
- ];
- protected $appends = ['second'];
- public function getSrcAttribute()
- {
- return isset($this->attributes['src']) ? config('console.pic_path').$this->attributes['src'] : NULL;
- }
- public function getPicAttribute()
- {
- return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL;
- }
- public function getSecondAttribute()
- {
- if (strstr($this->attributes['time'],":")){
- $timeArr = explode(':', $this->attributes['time']);
- return $timeArr[0]*60 + $timeArr[1];
- }else{
- return $this->attributes['time'];
- }
- }
- }
|