jeudi 10 mai 2018

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 Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KRxsVZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire