Skip to content

feat(filterable): support through() method to apply custom builder callbacks#2

Merged
kettasoft merged 3 commits intodevelopfrom
feature/through
Jul 30, 2025
Merged

feat(filterable): support through() method to apply custom builder callbacks#2
kettasoft merged 3 commits intodevelopfrom
feature/through

Conversation

@kettasoft
Copy link
Owner

Apply Custom Query Callbacks using through

This PR introduces the through() method to the Filterable class, enabling developers to apply an array of custom query modifications directly on the underlying Eloquent builder.

✨ What's Added

  • Filterable::through(array $callbacks) method
  • Each callback is applied sequentially on the query builder instance
  • Validates that each item in the array is a valid callable
  • Returns the same Filterable instance to support method chaining

✅ Tests

  • Added test: test_it_can_filter_with_through
  • Added test: test_it_throws_exception_for_invalid_through_callbacks

💡 Benefits

  • Gives more flexibility to inject dynamic or complex filters
  • Keeps logic clean and composable
  • Improves testability by isolating custom filter logic in callbacks

Abdalrhman Emad Saad added 3 commits July 29, 2025 13:46
…ing logic

- Introduced `when(bool $condition, callable $callback)` method to Filterable.
- Enables conditional modification of filter instances in a chainable, expressive way.
- Supports nested usage and enhances code clarity.
- Added full test coverage for true/false conditions and nested scenarios.
- Introduced through() method in Filterable to accept an array of closures
- Each closure is applied sequentially to the query builder
- Validates input to ensure only callables are accepted
- Added test cases to verify correct and incorrect usage
@kettasoft kettasoft merged commit 0bd858e into develop Jul 30, 2025
@kettasoft kettasoft deleted the feature/through branch August 17, 2025 17:25
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