Laravel Eloquent Get 3 Months

[Solved] Laravel Eloquent Get 3 Months | Php - Code Explorer | yomemimo.com
Question : laravel eloquent get 3 months

Answered by : lazy-lemur-4kj12f83alky

$dateS = Carbon::now()->startOfMonth()->subMonth(3);
$dateE = Carbon::now()->startOfMonth();
$TotalSpent = DB::table('orders')
->select('total_cost','placed_at')
->whereBetween('placed_at',[$dateS,$dateE])
->where(['deleted' => '0', 'delivery_address_id' => $DeliveryAddress->id])
->sum('total_cost');

Source : https://stackoverflow.com/questions/46172587/laravel-eloquent-select-between-current-month-and-previous-3-months/46178374 | Last Update : Sun, 14 Jun 20

Answers related to laravel eloquent get 3 months

Code Explorer Popular Question For Php