Home » Php » MySql Raw Query into Laravel 5.5 Eloquent ORM

MySql Raw Query into Laravel 5.5 Eloquent ORM

Posted by: admin October 20, 2018 Leave a comment

Questions:

I have mySql query an I want to convert it into Laravel 5.5 Eloquent ORM.

mySql Query:

SELECT i.category_id, count(i.id) as count FROM `items` i INNER JOIN item_categories c ON c.id = i.`category_id` GROUP BY i.`category_id`

This query is working. Is there any way to convert it easily into eloquent or anyone can make it for me.

Answers: