How to Get Last 30 Days Record in Laravel?
This article goes in detailed on laravel get last 30 days records. i explained simply about how to get last 30 days data from a table in laravel. In this article, we will implement a get last 30 days records in laravel. We will use laravel get last 30 days data from database.
we can easily get last 30 days records in laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version.
i will show you simple code of controller method where we written code to getting last 30 days records using carbon laravel eloquent.
let's see controller code:
class UserController extends Controller
* Write code on Method
* @return response()
public function index()
$date = Carbon::now()->subDays(30);
$users = User::where('created_at', '>=', $date)->get();
I hope it can help you...
We are Recommending you
- Laravel Eloquent firstOrNew Example
- Laravel Eloquent Delete Record By ID Example
- Laravel Eloquent inRandomOrder() Method Example
- Laravel Eloquent whereNull() Query Example
- Laravel Eloquent whereBetween() Query Example
- Laravel Eloquent whereRaw Condition Example
- Laravel Collection Merge | How to Merge Two Eloquent Collection?
- How to use whereHas with orWhereHas in Laravel?
- Laravel One to One Eloquent Relationship Tutorial
- Laravel - Where Condition with Two Columns Example