1
I am working on a database that has only as a reference to your foreign key, and I need to locate the last record according to your foreign key.
1
I am working on a database that has only as a reference to your foreign key, and I need to locate the last record according to your foreign key.
3
If you have the standard timestamp fields of the Laravel, you can give a
SuaClasse::where('chave_estrangeira', $chave)->orderBy('created_at', 'desc')->first();
Otherwise an option would be to orderby the ID in the same way, comparing the foreign key
Browser other questions tagged laravel
You are not signed in. Login or sign up in order to post.
Thank you Ademilson Santana da Silva saved my day!
– Richard Carlos