Illuminate\Database\Query\Builder::each PHP Method

each() public method

Execute a callback over each item while chunking.
public each ( callable $callback, integer $count = 1000 ) : boolean
$callback callable
$count integer
return boolean
    public function each(callable $callback, $count = 1000)
    {
        return $this->chunk($count, function ($results) use($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        });
    }