how to calculate total earning of current month in laravel?

585 Views Asked by At

Right now i am calculating total earning of the user yearly. But i want to show by month.

public function dashboard()
{
  $this->data['title'] = trans('backpack::base.dashboard');
  $customers = Tag::all();
  $total_earnings = 0;

  foreach ($customers as $customer) {
    if(Auth::User()->gym_code == $customer->gym_code)
      $total_earnings = $total_earnings + $customer->amount; 
  } 

  // set the page title
  $this->data['earnings'] = $total_earnings;
  return view('backpack::dashboard', $this->data);
}
0

There are 0 best solutions below