ProductAssistUser.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\model\store\product;
  3. use app\common\model\BaseModel;
  4. use app\common\model\system\merchant\Merchant;
  5. class ProductAssistUser extends BaseModel
  6. {
  7. /**
  8. * TODO
  9. * @return string
  10. * @author Qinii
  11. * @day 2020-10-12
  12. */
  13. public static function tablePk(): string
  14. {
  15. return 'product_assist_user_id';
  16. }
  17. /**
  18. * TODO
  19. * @return string
  20. * @author Qinii
  21. * @day 2020-10-12
  22. */
  23. public static function tableName(): string
  24. {
  25. return 'store_product_assist_user';
  26. }
  27. public function product()
  28. {
  29. return $this->hasOne(Product::class,'product_id','product_id');
  30. }
  31. public function assistSku()
  32. {
  33. return$this->hasMany(ProductAssistSku::class,'product_assist_id','product_assist_id');
  34. }
  35. public function merchant()
  36. {
  37. return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
  38. }
  39. // public function getAvatarImgAttr($value)
  40. // {
  41. // if(!$value){
  42. // $value = '/static/f.png';
  43. // }
  44. // return $value;
  45. // }
  46. public function searchProductAssistSetIdAttr($query,$value)
  47. {
  48. $query->where('product_assist_set_id',$value);
  49. }
  50. public function searchUidAttr($query,$value)
  51. {
  52. $query->where('uid',$value);
  53. }
  54. public function searchProductAssistIdAttr($query,$value)
  55. {
  56. $query->where('product_assist_id',$value);
  57. }
  58. }