jeudi 8 juillet 2021

why laravel overwrite two different veribales in query?

i am using this query to get 2 different results in $week_expence and $month_expence

 $week = \Carbon\Carbon::today()->subDays(7);
 $month = \Carbon\Carbon::today()->subDays(30);
 
 $expences =  SellerSell::where(['seller_id' => $id , 'order_confirmed_by' => $id ]);
 $week_expence = $expences->where('created_at','>=',$week)->sum('expenses');
 $month_expence = $expences->where('created_at','>=',$month)->sum('expenses');
 dd($week_expence , $month_expence);
    

consider if $week_expence = 10 and $month_expence = 20 then i get result in both veriables week and month is 10 why i am getting week expence in month?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3qSuk1A
via IFTTT

Aucun commentaire:

Enregistrer un commentaire