use Illuminate\Support\Carbon;
$stale_posts = Test::where('updated_at', '<', Carbon::now()->subDays(7))->get();
foreach ($stale_posts as $post) {
   $post->delete();
}
Leave a Comment