To get the last item I'm doing:
$balance = Balance::where('user_id', Auth::user()->id)->latest('created_at')->first();
I need to get the penultimate to be able to make a comparison of the result of the last balance and the penultimo .. I am trying to get the percentage difference from one to the other.
Read more here: https://stackoverflow.com/questions/66322727/how-to-know-the-penultimate-item-in-the-database-laravel
Content Attribution
This content was originally published by MullerBh at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.