PHP code example of itsimiro / laravel-chunk-cursor
1. Go to this page and download the library: Download itsimiro/laravel-chunk-cursor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itsimiro / laravel-chunk-cursor example snippets
use App\Models\User;
User::query()->with(['articles', 'friends'])->cursor()->each(function (User $users) {
// Process user... But 'articles' and 'friend' won't be loaded here :(
});
use App\Models\User;
User::query()->with(['articles', 'friends'])->chunkCursor(50)->each(function (Collection $users) {
foreach ($users as $user) {
// Process user... With eager loading! :)
}
});