Fresh code drop

Process big tables in chunks

PHP

Original CodeSnap example inspired by Laravel News. Source: https://laravel-news.com/eloquent-tips-tricks

PHP
CodeSnap // free canvas

Process big tables in chunks

<?php

User::query()->chunkById(500, function ($users): void {
    foreach ($users as $user) {
        SyncProfile::dispatch($user);
    }
});

// Further reading: https://laravel-news.com/eloquent-tips-tricks

Turn your code into a post.Five templates are free—no account needed.

Remix this snap