1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\model;
- use think\Model;
- use app\model\VideoType;
- class Video extends Model
- {
- public function getVideoUrlAttr($value)
- {
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
- public function getCoverAttr($value)
- {
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
- public function setCoverAttr($value){
- $domain = config('app.ali_oss_bindurl');
- $search = 'https://'.$domain.'/';
- return str_replace($search, '', $value);
- }
- public function setCoverShareImgAttr($value){
- $domain = config('app.ali_oss_bindurl');
- $search = 'https://'.$domain.'/';
- return str_replace($search, '', $value);
- }
- public function getCoverShareImgAttr($value){
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
-
- public function getTypeAttr($value)
- {
- if (empty($value)) return $value;
-
- $name = VideoType::where('id',$value)->value('name');
- return $name;
- }
-
- public function getLabelAttr($value)
- {
- if (empty($value)) return '';
- $name = VideoType::where('id',$value)->value('name');
- return $name;
- }
- public function employee(){
- return $this->belongsTo(Employee::class, 'employee_id', 'id');
- }
- public function setVideoUrlAttr($value)
- {
- if (empty($value)) return $value;
- $arr = explode(',',$value);
- return end($arr);
- }
- }
|