In this tutorial i’m going to learn how to delete all records older than 30 days. In this blog i have to mentioned in very easy to delete the records older than 30 days. If you want to keep only last 30 days records in your laravel application then i will give simple database query to delete all records older than 30 days in laravel.
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/07/image-49-1024x483.png)
Use below function to delete
public function index(Request $request)
{
Post::whereDate('created_at', '<=', now()->subDays(30))->delete();
}
I hope its helpful for you šš