HasOneMerchant.php 779 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace common\traits;
  3. use common\models\merchant\Merchant;
  4. /**
  5. * Trait HasOneMerchant
  6. * @package common\traits
  7. * @author jianyan74 <751393839@qq.com>
  8. */
  9. trait HasOneMerchant
  10. {
  11. /**
  12. * 关联商户
  13. *
  14. * @return mixed
  15. */
  16. public function getMerchant()
  17. {
  18. return $this->hasOne(Merchant::class, ['id' => 'merchant_id']);
  19. }
  20. /**
  21. * 关联商户
  22. *
  23. * @return mixed
  24. */
  25. public function getBaseMerchant()
  26. {
  27. return $this->hasOne(Merchant::class, ['id' => 'merchant_id'])->select([
  28. 'id',
  29. 'title',
  30. 'cover',
  31. 'address_name',
  32. 'address_details',
  33. 'longitude',
  34. 'latitude',
  35. 'collect_num',
  36. ]);
  37. }
  38. }
粤ICP备19079148号