ProductAssistUser.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\store\product;
  12. use app\common\model\BaseModel;
  13. use app\common\model\system\merchant\Merchant;
  14. class ProductAssistUser extends BaseModel
  15. {
  16. /**
  17. * TODO
  18. * @return string
  19. * @author Qinii
  20. * @day 2020-10-12
  21. */
  22. public static function tablePk(): string
  23. {
  24. return 'product_assist_user_id';
  25. }
  26. /**
  27. * TODO
  28. * @return string
  29. * @author Qinii
  30. * @day 2020-10-12
  31. */
  32. public static function tableName(): string
  33. {
  34. return 'store_product_assist_user';
  35. }
  36. public function product()
  37. {
  38. return $this->hasOne(Product::class,'product_id','product_id');
  39. }
  40. public function assistSku()
  41. {
  42. return$this->hasMany(ProductAssistSku::class,'product_assist_id','product_assist_id');
  43. }
  44. public function merchant()
  45. {
  46. return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
  47. }
  48. public function getAvatarImgAttr($value)
  49. {
  50. if(!$value){
  51. $value = '/static/f.png';
  52. }
  53. return $value;
  54. }
  55. public function searchProductAssistSetIdAttr($query,$value)
  56. {
  57. $query->where('product_assist_set_id',$value);
  58. }
  59. public function searchUidAttr($query,$value)
  60. {
  61. $query->where('uid',$value);
  62. }
  63. public function searchProductAssistIdAttr($query,$value)
  64. {
  65. $query->where('product_assist_id',$value);
  66. }
  67. }