Talkskill.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\model;
  3. use app\event\Msg;
  4. use think\Model;
  5. use app\model\TalkskillComment;
  6. use app\model\TalkskillLabel;
  7. class Talkskill extends Model
  8. {
  9. public function getLabelAttr($value)
  10. {
  11. if (empty($value)) return $value;
  12. $label = TalkskillLabel::where('id', 'in', $value)->column('label_name');
  13. $label = implode('#', $label);
  14. return '#' . $label;
  15. }
  16. public function getImgsAttr($value)
  17. {
  18. if (empty($value)) return $value;
  19. $arr = explode(',', $value);
  20. $domain = config('app.ali_oss_bindurl');
  21. foreach ($arr as &$item) {
  22. $item = 'https://' . $domain . '/' . $item;
  23. }
  24. return $arr;
  25. }
  26. public function getVideosAttr($value)
  27. {
  28. if (empty($value)) return $value;
  29. $arr = explode(',', $value);
  30. $domain = config('app.ali_oss_bindurl');
  31. foreach ($arr as &$item) {
  32. $item = 'https://' . $domain . '/' . $item;
  33. }
  34. return $arr;
  35. }
  36. public function employee()
  37. {
  38. return $this->belongsTo(Employee::class, 'employee_id')->bind(['name']);
  39. }
  40. public function aproveName()
  41. {
  42. return $this->belongsTo(Employee::class, 'aprove_employee_id')->bind(['aprove_name' => 'name']);
  43. }
  44. public function TalkskillComment()
  45. {
  46. return $this->hasMany(TalkskillComment::class, 'taid', 'id');
  47. }
  48. public function getMediaIdAttr($value)
  49. {
  50. if (empty($value)) return '';
  51. $arr = explode(',', $value);
  52. return $arr;
  53. }
  54. public function getWeixinMediaAttr($value)
  55. {
  56. if (empty($value)) return '';
  57. $arr = explode(',', $value);
  58. return $arr;
  59. }
  60. public function approveEmployee()
  61. {
  62. return $this->belongsTo(Employee::class, 'aprove_employee_id')->bind(['approve_name'=>'name','opt_name']);
  63. }
  64. public function employees()
  65. {
  66. return $this->belongsTo(Employee::class, 'employee_id');
  67. }
  68. }