Skip to content

Conversation

@bunyaminbilenkaratas
Copy link

Description

This PR adds a configurable scope name converter to allow customization of how filter property names are converted to Eloquent scope method names.

Changes

  • Added scope_name_converter config option with three modes:
    • camel (default): Converts to camelCase (e.g., published_atpublishedAt)
    • none: Uses exact property name without conversion
    • auto: Tries exact method name first, falls back to camelCase
  • Updated FiltersScope class to use the config
  • Added comprehensive tests for all converter modes
  • Resolves the TODO comment in FiltersScope::__invoke()

Backward Compatibility

This change is fully backward compatible. The default behavior (camel) remains unchanged.

Example Usage

// config/query-builder.php
'scope_name_converter' => 'none',

// Now filters respect the exact scope name:
GET /posts?filter[published_at]=2023
// Calls: scopePublished_at() instead of scopePublishedAt()

Resolves TODO in FiltersScope class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant