Eloquent merge two queries

Posted 11 months ago by cunlayogd

Hi all, how can I merge this two queries into a single query.

$jobLocations = DB::table('job_post_locations')
                     ->join('locations', 'job_post_locations.location_id', '=', 'locations.id')
                     ->select('locations.id','locations.name',DB::raw('count(*) as location_count'))
                     ->groupBy('location_id')
                     ->get();

        $jobIndustries = DB::table('job_post_industries')
                     ->join('industries', 'job_post_industries.industry_id', '=', 'industries.id')
                     ->select('industries.id','industries.name',DB::raw('count(*) as industry_count'))
                     ->groupBy('industry_id')
                     ->get();

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.