Get data on daily or monthly limit?
Good evening, guys, please help me for 4 hours. I've been puzzling, I can't do it.
There are several products in the database, and they have a purchase restriction,
Daily limit: 100 pcs.
Monthly limit: 1000 pcs.
If one product exceeds the limit of more than 100 or 1000, then the product with a different id is displayed from the base, but the characteristics are the same.
$count = 1000 ; $daily = Carbon::now()->startOfDay(); $month = Carbon::now()->subDays(30)->startOfDay(); $q = Shop::where('id','=',1) ->where([ ['limit_day','<=', $count ], ['created_at', '<=', $daily], ['limit_month', '<=', $count ], ['created_at', '>=', $month] ])->count();
Help yes guys really need your help, please!MySQL Anonymous, Nov 23, 2020
And that limit_day and limit_month go to zero every day / month?
You need to keep logs of purchases separately, then it will be possible to calculate the number of purchases today and the number of purchases per monthAnonymous
To place the code, please use CodePen or similar tool. Thanks you!