DailyWechatArticle.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class DailyWechatArticle extends Model
  5. {
  6. public function dailyWechatLabel()
  7. {
  8. return $this->belongsTo('dailyWechatLabel', 'festival_id')->bind(['label_name']);
  9. }
  10. public function user()
  11. {
  12. return $this->belongsTo('user', 'uid')->bind(['nickname', 'headimgurl']);
  13. }
  14. public function getPictureAttr($value)
  15. {
  16. if (empty($value)) return $value;
  17. $arr = explode(',', $value);
  18. $domain = config('app.ali_oss_bindurl');
  19. foreach ($arr as &$item) {
  20. $item = 'http://' . $domain . '/' . $item;
  21. }
  22. return $arr;
  23. }
  24. public function setPictureAttr($value)
  25. {
  26. $domain = config('app.ali_oss_bindurl');
  27. $search = 'http://' . $domain . '/';
  28. return str_replace($search, '', $value);
  29. }
  30. public function company()
  31. {
  32. return $this->belongsTo('Company','root_id','root_id')->bind(['company_name']);
  33. }
  34. public function employee(){
  35. return $this->hasOne(Employee::class, 'id','employee_id')->bind(['employee_name'=> 'opt_name']);
  36. }
  37. }