Delete query that has the very last date in laravel
I have a scenario where the record is like this:
date
-
2018-01-15
-
2018-01-16
Now what I need to do is just delete the very last date. I need to delete the query that has 2018-01-15
.
My code is like this:
public function deletelatDate()
{
// $datedel = '2018-04-03';
$datedel = Attendance::sortBy('date', 'desc')->first();
// $query->sortBy('date', 'desc')->first();
DB::table('attendances')->where('date', $datedel )->delete();
return back()->with('success','Last attendance entries successfully deleted');
}
Do you have any suggestions on how am I able to fix this?
Thanks.
from Laravel Questions and Answers https://laravelquestions.com/laravel/delete-query-that-has-the-very-last-date-in-laravel/
via Lzo Media
No comments:
Post a Comment