Laravel 6

Laravel 8 get data of last 7 days

Avatar de firea
firea

I'm using laravel 8 and I want to list data of the last 7 days for each row and when no data is found return null.

for example :

database table

column1     column2
10/28/2020      5
10/27/2020      6

what I need to return

10/28/2020      5
10/27/2020      null
10/26/2020      null
10/25/2020      null
10/24/2020      null
10/23/2020      null
10/22/2020      null
10/28/2020      6
10/27/2020      null
10/26/2020      null
10/25/2020      null
10/24/2020      null
10/23/2020      null
10/22/2020      null

there is any way to do this?

Posté il y a 2 ans

Vous ne pouvez pas répondre à ce sujet.