CdkeyLibrary.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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. /**
  14. * Class CdkeyLibrary
  15. * app\common\model\store\cdkey
  16. * 卡密库
  17. */
  18. class CdkeyLibrary extends BaseModel
  19. {
  20. /**
  21. * 主键
  22. */
  23. public static function tablePk(): string
  24. {
  25. return 'id';
  26. }
  27. /**
  28. * @return string
  29. * @author Qinii
  30. */
  31. public static function tableName(): string
  32. {
  33. return 'cdkey_library';
  34. }
  35. public function product()
  36. {
  37. return $this->hasOne(Product::class, 'product_id', 'product_id');
  38. }
  39. public function attrValue()
  40. {
  41. return $this->hasOne(ProductAttrValue::class, 'value_id', 'product_attr_value_id');
  42. }
  43. public function searchIdAttr($query, $value)
  44. {
  45. return $query->where('id', $value);
  46. }
  47. public function searchStatusAttr($query, $value)
  48. {
  49. return $query->where('status', $value);
  50. }
  51. }