Invoice.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. 'contract_money' => 'money'
  36. ]);
  37. }
  38. /**
  39. * 关联用户模型
  40. *
  41. * @return \think\model\relation\HasOne
  42. */
  43. public function toAdminUser()
  44. {
  45. return $this->hasOne('AdminUser', 'id', 'owner_user_id')->bind([
  46. 'owner_user_name' => 'realname'
  47. ]);
  48. }
  49. }