GuaranteeTemplate.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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;
  12. use app\common\model\BaseModel;
  13. class GuaranteeTemplate extends BaseModel
  14. {
  15. public static function tablePk(): string
  16. {
  17. return 'guarantee_template_id';
  18. }
  19. public static function tableName(): string
  20. {
  21. return 'guarantee_template';
  22. }
  23. public function templateValue()
  24. {
  25. return $this->hasMany(GuaranteeValue::class,'guarantee_template_id','guarantee_template_id');
  26. }
  27. public function getTemplateValueAttr()
  28. {
  29. return GuaranteeValue::haswhere('value',function($query){
  30. $query->where('status',1)->where('is_del',0);
  31. })
  32. ->where('guarantee_template_id',$this->guarantee_template_id)
  33. ->column('GuaranteeValue.guarantee_id');
  34. }
  35. public function searchGuaranteeTemplateIdAttr($query,$value)
  36. {
  37. $query->where('guarantee_template_id',$value);
  38. }
  39. public function searchMerIdAttr($query,$value)
  40. {
  41. $query->where('mer_id',$value);
  42. }
  43. public function searchKeywordAttr($query,$value)
  44. {
  45. $query->whereLike('template_name',"%{$value}%");
  46. }
  47. public function searchDateAttr($query,$value)
  48. {
  49. getModelTime($query,$value);
  50. }
  51. public function searchStatusAttr($query,$value)
  52. {
  53. $query->where('status',$value);
  54. }
  55. public function searchIsDelAttr($query,$value)
  56. {
  57. $query->where('is_del',$value);
  58. }
  59. }