laravel eloquent get 3 months

Solutions on MaxInterview for laravel eloquent get 3 months by the best coders in the world

showing results for - "laravel eloquent get 3 months"
Franco
26 Jan 2020
1$dateS = Carbon::now()->startOfMonth()->subMonth(3);
2$dateE = Carbon::now()->startOfMonth(); 
3$TotalSpent = DB::table('orders')
4->select('total_cost','placed_at')
5->whereBetween('placed_at',[$dateS,$dateE])
6->where(['deleted' => '0', 'delivery_address_id' => $DeliveryAddress->id])
7->sum('total_cost');