vendredi 19 octobre 2018

Laravel 5.7 - Filter a paginated query builder by an accessor?

I have a query builder that returns paginated data:

$builder = Example::latest();
        $examples = $builder->with([
                                'activity',
                                'followers',
                                'messages',
                                'assignedTeam',
                                'domain',
                                'history'])
                        ->paginate();

        return response()->json($examples);

The model has an accessor, isRelativeTo that is a boolean value. I want to filter this by !isRelativeTo. I know I can't map over it or add a filter directly, as it's not a collection, so wondering what the correct way of doing something like this might?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire