1
0

Article.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. use app\model\VideoType;
  5. class Article extends Model
  6. {
  7. /**
  8. * 图片拼接
  9. */
  10. public function getCoverImgAttr($value)
  11. {
  12. if (empty($value)) return $value;
  13. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  14. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  15. return $url;
  16. }
  17. public function setCoverImgAttr($value){
  18. $domain = config('app.ali_oss_bindurl');
  19. $search = 'https://'.$domain.'/';
  20. return str_replace($search, '', $value);
  21. }
  22. public function setCoverShareImgAttr($value){
  23. $domain = config('app.ali_oss_bindurl');
  24. $search = 'https://'.$domain.'/';
  25. return str_replace($search, '', $value);
  26. }
  27. public function getCoverShareImgAttr($value){
  28. if (empty($value)) return $value;
  29. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  30. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  31. return $url;
  32. }
  33. public function getTypeAttr($value)
  34. {
  35. if (empty($value)) return $value;
  36. $name = VideoType::where('id',$value)->value('name');
  37. return $name;
  38. }
  39. public function getLabelAttr($value)
  40. {
  41. if (empty($value)) return $value;
  42. $names = VideoType::where([['id','in',explode(',',$value)]])->column('name');
  43. return implode(',',$names);
  44. }
  45. public function employee(){
  46. return $this->hasOne(Employee::class, 'id','employee_id')->bind(['employee_name'=> 'opt_name']);
  47. }
  48. }