1
0

AgentArticle.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class AgentArticle extends Model
  5. {
  6. /**
  7. * 图片拼接
  8. */
  9. public function getFileAttr($value)
  10. {
  11. if (empty($value)) return $value;
  12. $array = explode(',', $value);
  13. $domain = config('app.ali_oss_bindurl');
  14. foreach($array as &$item){
  15. $item = 'https://'.$domain.'/'.$item;
  16. }
  17. return $array;
  18. }
  19. public function getCoverAttr($value)
  20. {
  21. if (empty($value)) return $value;
  22. $domain = config('app.ali_oss_bindurl');
  23. $item = 'https://'.$domain.'/'.$value;
  24. return $item;
  25. }
  26. public function getAddtimeAttr($value)
  27. {
  28. if (empty($value)) return $value;
  29. $date = date('Y-m-d H:i:s',$value);
  30. return $date;
  31. }
  32. public function clue()
  33. {
  34. return $this->hasMany(CustomerClue::class, 'pipe_id', 'id');
  35. }
  36. public function setFileAttr($value){
  37. $domain = config('app.ali_oss_bindurl');
  38. $search = 'https://'.$domain.'/';
  39. return str_replace($search, '', $value);
  40. }
  41. public function setCoverAttr($value){
  42. $domain = config('app.ali_oss_bindurl');
  43. $search = 'https://'.$domain.'/';
  44. return str_replace($search, '', $value);
  45. }
  46. public function employee()
  47. {
  48. return $this->hasOne(Employee::class, 'id', 'employee_id');
  49. }
  50. }