Skip to content

cursorPaginate breaks inRandomOrder #645

@francoism90

Description

@francoism90

I'm testing the newly introduced cursorPaginate, all seems to work fine, however using inRandomOrder results in:

{
    "message": "array_flip(): Can only flip string and integer values, entry skipped",
    "exception": "ErrorException",
    "file": "/home/user/www/src/api/vendor/laravel/framework/src/Illuminate/Collections/Collection.php",
    "line": 382,
..

Is this expected or a known bug? I'm simple calling a custom filter and works fine using paginate:

<?php

namespace App\Support\QueryBuilder\Sorters;

use Illuminate\Database\Eloquent\Builder;
use Spatie\QueryBuilder\Sorts\Sort;

class RandomSorter implements Sort
{
    public function __invoke(Builder $query, bool $descending, string $property): Builder
    {
        return $query->inRandomOrder();
    }
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions