Laravel: carbon addDays()

I am trying to display posts for only 5 days after they are created. I have added $date->addDays(5) to my controller, but nothing is showing in my blade. Here is my controller:

use Carbon\Carbon;
...
public function index(){

   $date = Carbon::now();
   $date->addDays(5);
   $date->format("Y-m-d");
   $posts = Post::where('status','=', 1)->whereDate('created_at','=', $date)->get();
   return view('home', compact('date', $date))->with('posts', $posts);
}
...

And this is my home.blade.php:

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">All posts
                    <a href="/posts/create" class="btn btn-primary" style="margin-left: 70%">New post +</a></div>
                <hr>
                <div class="card-body">
                    @foreach($posts as $post)
                        @if($post->status == 1)
                            <small style="color:red">PREMIUM POST</small>
                            <hr>
                        @endif
                        <h2>{{$post->name}}</h2><br>
                        <medium>{{$post->body}}</medium>
                        <hr style="border: 1.5px solid grey">
                    @endforeach
                    <small><?php echo now() ?></small>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Why are my posts not being displayed in my blade? I am expecting them to show for 5 days after creation.

The whereDate() method expects a date in the format Y-m-d, but $date is not being formatted correctly. To fix the issue, change this line:

$date->format("Y-m-d");

to:

$dateFormatted = $date->format("Y-m-d");

Then, use $dateFormatted in your whereDate() method:

$posts = Post::where('status','=', 1)->whereDate('created_at','=', $dateFormatted)->get();

This should display the posts created in the last 5 days.