newQuery(); if(!$user){ return $query->where('id','0'); } $ownerIds=app('UserService')->getPermittingOwnerIds($user); if(empty($ownerIds))return $query; return $query->whereIn('id',$ownerIds); } /** * 退货管理里,客户审核的代码,是拼音+日期+计数,计数的后缀就是checking_count * @return int|mixed */ public function getIncreasedCheckingCount(){ $this['checking_count']=$this['checking_count']+1; $this->update(); return $this['checking_count']; } public function paperBoxes() { return $this->belongsToMany('\App\PaperBox', 'owner_paper_box', 'owner_id', 'paper_box_id'); } public function orderTrackingOwner(){ return $this->belongsTo(OrderTrackingOwner::class,'id','owner_id'); } public function contracts() { //合同 return $this->hasMany(OwnerContract::class,"owner_id","id"); } public function order(){ return $this->hasOne(Order::class,'owner_id','id'); } public function customer() { //客户 return $this->hasOne(Customer::class,"id","customer_id"); } public function userOwnerGroup() { //项目组 return $this->hasOne(UserOwnerGroup::class,"id","user_owner_group_id"); } public function ownerStoragePriceModels() { //仓储计费 return $this->belongsToMany(OwnerStoragePriceModel::class,"owner_storage_price_model_owner","owner_id","owner_storage_price_model_id"); } public function ownerAreaReport() { //面积报表 return $this->hasOne(OwnerAreaReport::class,"owner_id","id"); } public function ownerPriceOperations() { //作业计费 return $this->belongsToMany(OwnerPriceOperation::class,"owner_price_operation_owner","owner_id","owner_price_operation_id"); } public function ownerPriceExpresses() { //快递计费 return $this->belongsToMany(OwnerPriceExpress::class,"owner_price_express_owner","owner_id","owner_price_express_id"); } public function ownerPriceLogistics() { //物流计费 return $this->belongsToMany(OwnerPriceLogistic::class,"owner_price_logistic_owner","owner_id","owner_price_logistic_id"); } public function ownerPriceDirectLogistics() { //直发车计费 return $this->belongsToMany(OwnerPriceDirectLogistic::class,"owner_price_direct_logistic_owner","owner_id","owner_price_direct_logistic_id"); } public function warehouse() { //仓库 return $this->belongsTo(Warehouse::class,"warehouse_id","id"); } }