lundi 2 août 2021

Laravel Make weekly Dynamic Json Array

I have 2 dates like start date and end date and one string like 2w2,1w1,3w3,4w3

In this 2w2 => first 2 means 2 class in 1 week and second 2 class in 2nd week, which means 2 classes till 2 weeks, if 1w1 then 1 class in 1 week,3w3 then 3 class till 3 weeks. now I want to make JSON array likes, week start date, weekend date, and frequency according to that week, Please suggest to me how to make it.

 $week_array = [{"startdate":"2021-07-18","enddate":"2021-07-24","frequency":2},
                {"startdate":"2021-07-25","enddate":"2021-07-31","frequency":2},
                {"startdate":"2021-08-01","enddate":"2021-08-07","frequency":1},
                {"startdate":"2021-08-08","enddate":"2021-08-14","frequency":3}]

Week starts from Sunday to Saturday.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire