Get Current Week Records Query Example In Laravel

Hi Artisan,

Now, let's see an example of how to get current week data in laravel. I will simply show you about laravel get current week data. This post will give you a simple example of getting current week data in laravel. you can see laravel wherebetween current week data.

Let's get started with laravel where between dates. We can get current week records in laravel application. Here, I will give you a very simple example of how to get the current week record in laravel. You will use whereBetween() and Carbon Object for a date in this example.

I will use Carbon to get weekly data in laravel. So see the below code to get weekly data in Laravel:

Example code:

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Http;
use App\Models\Item;
use Carbon\Carbon;
class TestController extends Controller
     * Write code on Method
     * @return response()
    public function index()
        $items = Item::select("*")
                        [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()]


Read also: API Authentication Tutorial with Laravel Passport


Hope it can help you.


#laravel #carbon