I am trying to select columns (id, title) of the relationship database (product_detail) but it's not working at all.
My Query:
RoomProduct::select('product_id', DB::raw('SUM(value) as total'))
->whereHas('room.offer', function($sql) use ($offer_id) {
$sql->where('id', $offer_id);
})->whereHas('product_detail', function($sql) use ($category_id) {
$sql->select("id", "title")->with(['category' => function ($query) {
$query->where('parent_id', $category_id);
}])->orWhere('id', $category_id);
})->groupBy("product_id")->get();