123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\admin\model;
- use think\Model;
- use think\model\relation\BelongsTo;
- use think\model\relation\HasMany;
- use think\model\relation\HasOne;
- class MobileOrder extends \app\common\model\MobileOrder
- {
- protected $relationSearch = true;
- protected $hidden=[];
-
- public function getPhoneOrderCountAttr(){
- $no=$this['phone'];
- static $arr=[];
- if(!isset($arr[$no])){
- $arr[$no]=self::where('phone',$no)->where('type',1)->count();
- }
- return $arr[$no];
- }
-
- public function getPhoneOrderFlowCountAttr(){
- $no=$this['phone'];
- static $arr=[];
- if(!isset($arr[$no])){
- $arr[$no]=self::where('phone',$no)->where('type',2)->count();
- }
- return $arr[$no];
- }
- public function subRemark(): HasMany
- {
- return $this->hasMany(MobileOrderSubRemark::class)->order('mobile_order_sub_remark.mobile_order_sub_remark_id','desc');
- }
- public function subAnchor(): HasOne
- {
- return $this->hasOne(MobileOrderSubAnchor::class);
- }
- public function anchor(): BelongsTo
- {
- return $this->belongsTo(MobileAnchor::class,'mobile_anchor_id','id',[],'left')->setEagerlyType(0);
- }
- }
|