how to get relations data of joined table laravel eloquet query code example
Example 1: count with left join in laravel
$areas = Area::select('areas.*', DB::raw('count(area_id) as connections'))
->leftJoin('object_areas', 'object_areas.area_id', '=', 'areas.id')
->groupBy('areas.id')
->get();
Example 2: count with left join in laravel
$areas = Area::select('areas.*', DB::raw('count(area_id) as connections'))
->leftJoin('object_areas', 'object_areas.area_id', '=', 'areas.id')
->groupBy('areas.id')
->get();