123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Models;
- class MentalityDrillExtend extends SoftBaseModel
- {
- /**
- * 类别 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'];
- }
- }
- }
|