N
N
Nubbin2017-10-24 16:52:59
MySQL
Nubbin, 2017-10-24 16:52:59

Get daily or monthly limit data?

Good evening, guys, please help me for 4 hours I have been racking my brains and I can’t do it.
There are several products in the database, and they have a purchase limit,
Daily limit: 100 pcs.
Monthly limit: 1000 pcs.
If one product has a limit greater than 100 or 1000, then the product with a different id is displayed from the database, 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();

Does not help.
Help yes guys really need your help please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Gerasimov, 2017-10-24
@Omashu

And that limit_day and limit_month go to zero every day/month?
You need to keep purchase logs separately, then it will be possible to calculate the number of purchases today and the number of purchases per month

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question