MobileOrder.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. use think\model\relation\BelongsTo;
  5. use think\model\relation\HasMany;
  6. use think\model\relation\HasOne;
  7. class MobileOrder extends \app\common\model\MobileOrder
  8. {
  9. protected $relationSearch = true;
  10. protected $hidden=[];
  11. public function getPhoneOrderCountAttr(){
  12. $no=$this['phone'];
  13. static $arr=[];
  14. if(!isset($arr[$no])){
  15. $arr[$no]=self::where('phone',$no)->where('type',1)->count();
  16. }
  17. return $arr[$no];
  18. }
  19. public function getPhoneOrderFlowCountAttr(){
  20. $no=$this['phone'];
  21. static $arr=[];
  22. if(!isset($arr[$no])){
  23. $arr[$no]=self::where('phone',$no)->where('type',2)->count();
  24. }
  25. return $arr[$no];
  26. }
  27. public function subRemark(): HasMany
  28. {
  29. return $this->hasMany(MobileOrderSubRemark::class)->order('mobile_order_sub_remark.mobile_order_sub_remark_id','desc');
  30. }
  31. public function subAnchor(): HasOne
  32. {
  33. return $this->hasOne(MobileOrderSubAnchor::class);
  34. }
  35. public function anchor(): BelongsTo
  36. {
  37. return $this->belongsTo(MobileAnchor::class,'mobile_anchor_id','id',[],'left')->setEagerlyType(0);
  38. }
  39. }