I am trying to pull all the users whose created_at date has been more than 10 days from today. I know that I should be using Carbon package for this and here is my take:
$users = Users::where('status_id', 'active')
->where( 'created_at', '<', Carbon::now())
What’s the right way to get Laravel Carbon to work for me on this case ?
Laravel Carbon is an amazing library that you can use to play with dates and go back and forth on formatting and calculations. What you can use is subDays() method:
->where( 'created_at', '>', Carbon::now()->subDays(10))