123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\model;
- use think\Model;
- use app\model\VideoType;
- class Article extends Model
- {
- /**
- * 图片拼接
- */
- public function getCoverImgAttr($value)
- {
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
- public function setCoverImgAttr($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 $value;
- $names = VideoType::where([['id','in',explode(',',$value)]])->column('name');
- return implode(',',$names);
- }
- public function employee(){
- return $this->hasOne(Employee::class, 'id','employee_id')->bind(['employee_name'=> 'opt_name']);
- }
- }
|