public function query($m = 0) { //m==0:我的好友;1:新的申请;2:寻找好友 if ($m == 0) { $datas = UserFrieldModel::where('isauth', 3)->where(function ($query) { $query->where('uid', $this->userid)->where('frield_id', $this->userid); })->orderBy('id', 'desc')->paginate($this->limit); } elseif ($m = 1) { $datas = UserFrieldModel::where('isauth', 1)->where('frield_id', $this->userid)->orderBy('id', 'desc')->paginate($this->limit); } elseif ($m = 2) { $datas = UserModel::where('id', '>', $this->userid)->orderBy('id', 'desc')->paginate($this->limit); } $datas->limit = $this->limit; return $datas; }
/** * 好友数量 */ public function frields() { return UserFrieldModel::where('del', 0)->where(function ($query) { $query->where('uid', $this->userid)->where('frield_id', $this->userid); })->where('isauth', 2)->get(); }