Video.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. use app\model\VideoType;
  5. class Video extends Model
  6. {
  7. public function getVideoUrlAttr($value)
  8. {
  9. if (empty($value)) return $value;
  10. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  11. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  12. return $url;
  13. }
  14. public function getCoverAttr($value)
  15. {
  16. if (empty($value)) return $value;
  17. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  18. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  19. return $url;
  20. }
  21. public function setCoverAttr($value){
  22. $domain = config('app.ali_oss_bindurl');
  23. $search = 'https://'.$domain.'/';
  24. return str_replace($search, '', $value);
  25. }
  26. public function setCoverShareImgAttr($value){
  27. $domain = config('app.ali_oss_bindurl');
  28. $search = 'https://'.$domain.'/';
  29. return str_replace($search, '', $value);
  30. }
  31. public function getCoverShareImgAttr($value){
  32. if (empty($value)) return $value;
  33. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  34. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  35. return $url;
  36. }
  37. public function getTypeAttr($value)
  38. {
  39. if (empty($value)) return $value;
  40. $name = VideoType::where('id',$value)->value('name');
  41. return $name;
  42. }
  43. public function getLabelAttr($value)
  44. {
  45. if (empty($value)) return '';
  46. $name = VideoType::where('id',$value)->value('name');
  47. return $name;
  48. }
  49. public function employee(){
  50. return $this->belongsTo(Employee::class, 'employee_id', 'id');
  51. }
  52. public function setVideoUrlAttr($value)
  53. {
  54. if (empty($value)) return $value;
  55. $arr = explode(',',$value);
  56. return end($arr);
  57. }
  58. }