public function home() { if (Auth::check()) { $title = 'home'; if (Auth::user()->identifier == 1) { $sort_by = " "; $sort_by_skill = " "; $searchskill = ["css", "php"]; // $searchskill = implode(',', $searchskill); // $searchskill = explode(',', $searchskill); $skills = Skills::lists('name', 'name'); $submitFilter = " "; $filter = Filter::where('post_type', '=', 'job')->where('from_user', '=', Auth::user()->id)->first(); $skillfilter = Filter::where('post_type', '=', 'skill')->where('from_user', '=', Auth::user()->id)->first(); // $mobileReg = User::where('induser_id', '=', Auth::user()->induser_id) // ->where('mobile', '=', '9686458736') // ->first(['mobile']); // return $mobileReg; $jobPosts = Postjob::orderBy('id', 'desc')->with('indUser', 'corpUser', 'postActivity', 'taggedUser', 'taggedGroup', 'preferLocations')->where('post_type', '=', 'job')->where('individual_id', '!=', Auth::user()->induser_id)->where('inactive', '=', 0)->whereRaw('postjobs.id in (select pm.id from postjobs pm where pm.id in ( select p.id from postjobs p LEFT JOIN post_group_taggings pgt on pgt.post_id = p.id left join groups_users gu on gu.group_id = pgt.group_id left join indusers ind on ind.id = gu.user_id left join indusers indg on indg.id = pgt.tag_share_by where ind.id = ' . Auth::user()->induser_id . ' union select p.id from postjobs p left join post_user_taggings put on put.post_id = p.id left join indusers ind on ind.id = put.user_id left join indusers inds on inds.id = put.tag_share_by where ind.id = ' . Auth::user()->induser_id . ' ) union select pm.id from postjobs pm where pm.id not in ( select distinct pgt.post_id from post_group_taggings pgt union select distinct put.post_id from post_user_taggings put )) ')->orWhere('corporate_id', '>', 0)->paginate(5); $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'); $skillPosts = Postjob::orderBy('id', 'desc')->with('indUser', 'corpUser', 'postActivity', 'taggedUser', 'taggedGroup', 'preferLocations')->where('post_type', '=', 'skill')->where('individual_id', '!=', Auth::user()->induser_id)->where('inactive', '=', 0)->whereRaw('postjobs.id in (select pm.id from postjobs pm where pm.id in ( select p.id from postjobs p LEFT JOIN post_group_taggings pgt on pgt.post_id = p.id left join groups_users gu on gu.group_id = pgt.group_id left join indusers ind on ind.id = gu.user_id left join indusers indg on indg.id = pgt.tag_share_by where ind.id = ' . Auth::user()->induser_id . ' union select p.id from postjobs p left join post_user_taggings put on put.post_id = p.id left join indusers ind on ind.id = put.user_id left join indusers inds on inds.id = put.tag_share_by where ind.id = ' . Auth::user()->induser_id . ' ) union select pm.id from postjobs pm where pm.id not in ( select distinct pgt.post_id from post_group_taggings pgt union select distinct put.post_id from post_user_taggings put )) ')->paginate(5); $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); 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 $searchskill; return view('pages.home', compact('jobPosts', 'skillPosts', 'groups', 'title', 'links', 'following', 'userSkills', 'skills', 'linksApproval', 'linksPending', 'share_links', 'share_groups', 'sort_by', 'sort_by_skill', 'filter', 'skillfilter', 'submitFilter')); // return $skillPosts; } elseif (Auth::user()->identifier == 2) { $sort_by = " "; $sort_by_skill = " "; $skills = Skills::lists('name', 'name'); $filter = Filter::where('post_type', '=', 'job')->where('from_user', '=', Auth::user()->id)->first(); $skillfilter = Filter::where('post_type', '=', 'skill')->where('from_user', '=', Auth::user()->id)->first(); $skillPosts = Postjob::orderBy('id', 'desc')->with('indUser', 'corpUser', 'postActivity', 'taggedUser', 'taggedGroup')->where('post_type', '=', 'skill')->where('inactive', '=', 0)->paginate(5); 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); } return view('pages.home_corporate', compact('jobPosts', 'skillPosts', 'title', 'following', 'skills', 'sort_by', 'sort_by_skill', 'filter', 'skillfilter')); } elseif (Auth::user()->identifier == 3) { $reportAbuseCount = ReportAbuse::count(); $feedbackCount = Feedback::count(); $expFeedCounts = DB::select(DB::raw(' select (select count(experience) from feedbacks f where f.experience = 5) as five, (select count(experience) from feedbacks f where f.experience = 4) as four, (select count(experience) from feedbacks f where f.experience = 3) as three, (select count(experience) from feedbacks f where f.experience = 2) as two, (select count(experience) from feedbacks f where f.experience = 1) as one from dual; ')); $useFeedCounts = DB::select(DB::raw(' select (select count(usability) from feedbacks f where f.usability = "Hard") as hard, (select count(usability) from feedbacks f where f.usability = "Okay") as okay, (select count(usability) from feedbacks f where f.usability = "Easy") as easy from dual; ')); return view('pages.dashboard', compact('title', 'reportAbuseCount', 'feedbackCount', 'expFeedCounts', 'useFeedCounts')); } } else { return redirect('login'); } }