コード例 #1
0
    public function friendLink($utype, $id)
    {
        $title = 'friendLink';
        if ($utype == 'ind') {
            $linkName = Induser::findOrFail($id);
            $linkFollow = Corpuser::leftjoin('follows', 'corpusers.id', '=', 'follows.corporate_id')->where('follows.individual_id', '=', $id)->get(['corpusers.id', 'corpusers.firm_name', 'corpusers.logo_status', 'corpusers.operating_since', 'corpusers.city', 'follows.corporate_id', 'follows.individual_id']);
            $followCount = Follow::Where('individual_id', '=', $id)->count('id');
            $connections = DB::select('select id,fname,lname,working_at,city,state,profile_pic from indusers
										where indusers.id in (
										select connections.user_id as id from connections
										where connections.connection_user_id=?
										 and connections.status=1 
										union 
										select connections.connection_user_id as id from connections
										where connections.user_id=?
										 and connections.status=1
									)', [$id, $id]);
            $linksCount = Connections::where('user_id', '=', $id)->where('status', '=', 1)->orWhere('connection_user_id', '=', $id)->where('status', '=', 1)->count('id');
            return view('pages.friendlink', compact('linkName', 'title', 'linkFollow', 'connections', 'linksCount', 'followCount', 'utype'));
        } elseif ($utype == 'corp') {
            $followers = Corpuser::find($id)->followers;
            return view('pages.friendlink', compact('title', 'followers', 'utype'));
        }
    }