public function singleSkillPost($id) { if (Auth::check()) { $title = 'home'; if (Auth::user()->identifier == 1 || Auth::user()->identifier == 2) { $sort_by = " "; $sort_by_skill = " "; $skills = Skills::lists('name', 'name'); $post = Postjob::orderBy('id', 'desc')->with('indUser', 'corpUser', 'postActivity', 'taggedUser', 'taggedGroup')->where('unique_id', '=', $id)->where('inactive', '=', 0)->get(); if ($post != null) { $post = $post->first(); } $postviewCount = Postjob::where('unique_id', '=', $id)->first(); if ($postviewCount != null) { $postviewCount->postview_count = $postviewCount->postview_count + 1; $postviewCount->save(); } $postUser = Postjob::join('indusers', 'indusers.id', '=', 'postjobs.individual_id')->where('unique_id', '=', $id)->where('inactive', '=', 0)->first(); $links = DB::select('select id 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 )', [Auth::user()->induser_id, Auth::user()->induser_id]); $links = collect($links); $linksApproval = DB::select('select id from indusers where indusers.id in ( select connections.user_id as id from connections where connections.connection_user_id=? and connections.status=0 )', [Auth::user()->induser_id]); $linksApproval = collect($linksApproval); $linksPending = DB::select('select id from indusers where indusers.id in ( select connections.connection_user_id as id from connections where connections.user_id=? and connections.status=0 )', [Auth::user()->induser_id]); $linksPending = collect($linksPending); $groups = Group::leftjoin('groups_users', 'groups_users.group_id', '=', 'groups.id')->where('groups.admin_id', '=', Auth::user()->induser_id)->orWhere('groups_users.user_id', '=', Auth::user()->induser_id)->groupBy('groups.id')->get(['groups.id as id'])->lists('id'); if (Auth::user()->induser_id != null) { $following = DB::select('select id from corpusers where corpusers.id in ( select follows.corporate_id as id from follows where follows.individual_id=? )', [Auth::user()->induser_id]); $following = collect($following); } if (Auth::user()->corpuser_id != null) { $following = DB::select('select id from indusers where indusers.id in ( select follows.individual_id as id from follows where follows.corporate_id=? )', [Auth::user()->corpuser_id]); $following = collect($following); } if (Auth::user()->identifier == 1) { $userSkills = Induser::where('id', '=', Auth::user()->induser_id)->first(['linked_skill']); $userSkills = array_map('trim', explode(',', $userSkills->linked_skill)); unset($userSkills[count($userSkills) - 1]); } if (Auth::user()->identifier == 1) { $share_links = Induser::whereRaw('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 )', [Auth::user()->induser_id, Auth::user()->induser_id])->get(['id', 'fname'])->lists('fname', 'id'); $share_groups = Group::leftjoin('groups_users', 'groups_users.group_id', '=', 'groups.id')->where('groups.admin_id', '=', Auth::user()->induser_id)->orWhere('groups_users.user_id', '=', Auth::user()->induser_id)->groupBy('groups.id')->get(['groups.id as id', 'groups.group_name as name'])->lists('name', 'id'); } return view('pages.postDetails', compact('post', 'title', 'links', 'groups', 'following', 'userSkills', 'skills', 'linksApproval', 'linksPending', 'share_links', 'share_groups', 'sort_by', 'sort_by_skill', 'postUser')); // return $jobPosts; } } else { return redirect('login'); } }