GuaranteeTemplate.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\common\model\store;
  3. use app\common\model\BaseModel;
  4. class GuaranteeTemplate extends BaseModel
  5. {
  6. public static function tablePk(): string
  7. {
  8. return 'guarantee_template_id';
  9. }
  10. public static function tableName(): string
  11. {
  12. return 'guarantee_template';
  13. }
  14. public function templateValue()
  15. {
  16. return $this->hasMany(GuaranteeValue::class,'guarantee_template_id','guarantee_template_id');
  17. }
  18. public function getTemplateValueAttr()
  19. {
  20. return GuaranteeValue::haswhere('value',function($query){
  21. $query->where('status',1)->where('is_del',0);
  22. })
  23. ->where('guarantee_template_id',$this->guarantee_template_id)
  24. ->column('GuaranteeValue.guarantee_id');
  25. }
  26. public function searchGuaranteeTemplateIdAttr($query,$value)
  27. {
  28. $query->where('guarantee_template_id',$value);
  29. }
  30. public function searchMerIdAttr($query,$value)
  31. {
  32. $query->where('mer_id',$value);
  33. }
  34. public function searchKeywordAttr($query,$value)
  35. {
  36. $query->whereLike('template_name',"%{$value}%");
  37. }
  38. public function searchDateAttr($query,$value)
  39. {
  40. getModelTime($query,$value);
  41. }
  42. public function searchStatusAttr($query,$value)
  43. {
  44. $query->where('status',$value);
  45. }
  46. public function searchIsDelAttr($query,$value)
  47. {
  48. $query->where('is_del',$value);
  49. }
  50. }