123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 发票表
  4. *
  5. * @author qifan
  6. * @data 2020-12-07
  7. */
  8. namespace app\crm\model;
  9. use app\admin\model\Common;
  10. class Invoice extends Common
  11. {
  12. protected $name = 'crm_invoice';
  13. protected $pk = 'invoice_id';
  14. protected $dateFormat = "Y-m-d H:i:s";
  15. /**
  16. * 关联用户模型
  17. *
  18. * @return \think\model\relation\HasOne
  19. */
  20. public function toCustomer()
  21. {
  22. return $this->hasOne('Customer', 'customer_id', 'customer_id')->bind([
  23. 'customer_name' => 'name'
  24. ]);
  25. }
  26. /**
  27. * 关联合同模型
  28. *
  29. * @return \think\model\relation\HasOne
  30. */
  31. public function toContract()
  32. {
  33. return $this->hasOne('Contract', 'contract_id', 'contract_id')->bind([
  34. 'contract_number' => 'num',
  35. ]);
  36. }
  37. /**
  38. * 关联用户模型
  39. *
  40. * @return \think\model\relation\HasOne
  41. */
  42. public function toAdminUser()
  43. {
  44. return $this->hasOne('AdminUser', 'id', 'owner_user_id')->bind([
  45. 'owner_user_name' => 'realname'
  46. ]);
  47. }
  48. }