CustomerService.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\admin\model\shopro\chat;
  3. use app\admin\model\shopro\Common;
  4. use app\admin\model\shopro\chat\Record;
  5. use app\admin\model\shopro\chat\CustomerServiceUser;
  6. use app\admin\model\shopro\chat\traits\ChatCommon;
  7. class CustomerService extends Common
  8. {
  9. use ChatCommon;
  10. protected $name = 'shopro_chat_customer_service';
  11. protected $append = [
  12. 'auth_model',
  13. 'auth_text',
  14. 'status_text',
  15. 'room_name'
  16. ];
  17. // 自动数据类型转换
  18. protected $type = [
  19. 'last_time' => 'timestamp',
  20. ];
  21. public function statusList()
  22. {
  23. return ['offline' => '离线', 'online' => '在线', 'busy' => '忙碌'];
  24. }
  25. public function getAuthModelAttr($value, $data)
  26. {
  27. return $this->customer_service_user['auth_model'] ?? null;
  28. }
  29. public function getAuthTextAttr($value, $data)
  30. {
  31. return $this->customer_service_user['auth_text'] ?? null;
  32. }
  33. public function customerService()
  34. {
  35. return $this->morphMany(Record::class, ['sender_identify', 'sender_id'], 'customer_service');
  36. }
  37. public function customerServiceUser()
  38. {
  39. return $this->HasOne(CustomerServiceUser::class, 'customer_service_id');
  40. }
  41. }