I am trying to display rows that show the highest Version of each Name. However, I'm having problems on how to convert my raw php code to Eloquent ORM. Any help will be appreciated.
$sql="SELECT * FROM images WHERE (Name,Version) IN (SELECT Name, MAX(Version) FROM images GROUP by Name)";
Edit:
This is my code that I tried so far, it shows unique names but it doesn't show the name's highest version.
$items=Item::orderBy("version","DESC")->groupBy('model_name')->latest()->paginate(5);