Laravel Get Record Last Week, Month, 15 Days, Year

In this tutorial you will learn about the Laravel Get Record Last Week, Month, 15 Days, Year and its application with practical example.

In this Laravel Get Record Last Week, Month, 15 Days, Year tutorial I will  show you how to fetch records for last 1, 3, 6, 12 months and get the last date, last week, last, month, last year data records in laravel. In this tutorial you will learn how to get the last 1, 3, 6, 12 months, the last date, last week, last, month, last year data records in laravel.

Laravel Get Record Last Week, Month, 15 Days, Year

Table Of Content

  • Laravel Get Last Day Records
  • Get Last Week Data in Laravel
  • Laravel Get Last Month Records
  • Get Last 15 Days & 30 Days Records in Laravel
  • Fetch Month Wise Last Year Data
  • Fetch Last Year Record

Laravel Get Last Day Records

If you want to fetch records for last day from database tables. Provided eloquent Query can be used to fetch records for last day.

The output of the above laravel eloquent query looks like:

Get Last Week Data in Laravel

If you want to fetch records for current date from last week. Provided eloquent Query can be used to fetch records for last week. You can use the laravel eloquent method whereBetween to get the last week records from the database table as follow:

The output of the above laravel eloquent query looks like:

Laravel Get Last Month records

If you want to fetch records for last month from database tables. Provided eloquent Query can be used to fetch records for last month.

This query uses laravel method whereMonth() and get().

The output of the above laravel Eloquent query look like

Get Last 15 Days & 30 Days Records in Laravel

If you want to fetch records for last 15 days or 30 Days from database tables. Provided eloquent Query can be used to fetch records for last 15 days or 30 days.

Laravel Get Last Year Record

If you want to fetch records for last year from database tables. Provided eloquent Query can be used to fetch records for last year.

This query users laravel method whereYear() and get() to fetch records from db.

The output of above laravel eloquent query looks like

Fetch Month Wise Last Year Data

If you want to fetch month wise records from database tables. Provided eloquent Query can be used to fetch month wise records. You can use the laravel db::raw(), whereYear() and groupBy() to get previous year data month wise from the database table as follow:

The output of the above laravel eloquent query looks like

In this tutorial we have learn about the Laravel Get Record Last Week, Month, 15 Days, Year and its application with practical example. I hope you will like this tutorial.