php - Laravel get last row for each items -


i use laravel eloquent , have table:

id  client_id  project_id  status_id 1       1          1         1 2       2          1         1 3       1          1         2 4       2          1         2 

i want take last row insert each client. how can do?

since laravel offers method 'first' take first matching record, how first order descending , take first row?

$affectedrow = tablename::where(condition)->orderby('id', 'desc')->first();


Comments