Get last year created records in Laravel

You can get the last year created records in Laravel. You can use whereYear() method which will help you to get the previous year records from database table.

Answers 1
  • Get last year created records in Laravel

    App\Models\User::whereYear('created_at', date('Y', strtotime('-1 year')))->get();
    
    0

    You can get last year records in Laravel using whereYear() method. This code snippet will return all the user records from users table which are created at previous year.

  • Back to code snippet queries related laravel