Create eloquent Query in Readable to query that take the longest date of the column and show a vehicle of each

Asked

Viewed 18 times

0

inserir a descrição da imagem aqui

I need to show a vehicle of each (Vehicle), which sort by larger datatime('datetime_write), how do I create this query with eloquent in the Laravel?

1 answer

1

Assuming the eloquent model name is Sale, you need to sort by the datetime_write field in descending order and group by vehicle_id

Venda::ordeyBy('datetime_write', 'desc')->groupBy('vehicle_id')->get();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.