Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to improve the filtering capabilities and add new relationships in the models. The most important changes include refactoring the
Resolve
class methods, updating theFilterable
trait, enhancing thePost
,Book
, andProduct
models, and adding new tests for relation filtering.Refactoring and Enhancements:
src/Filters/Resolve.php
: Refactored thevalidate
andsafe
methods to improve readability and reliability. Added new methodsprepareModelForRelation
andrestorePreviousModel
to handle model relations more cleanly. [1] [2] [3]src/Traits/Filterable.php
: Updated thescopeFilter
andbootFilter
methods to use theResolve
class directly, improving dependency management and code clarity. [1] [2]Model Updates:
tests/App/Models/Book.php
: Added aposts
method to establish a morph-many relationship with thePost
model.tests/App/Models/Post.php
: Added apostable
method to establish a morph-to relationship and included theuser_id
field in the fillable properties. [1] [2]tests/App/Models/Product.php
: Addedposts
andbook
methods to establish morph-many and has-one relationships, respectively.Testing Enhancements:
tests/Feature/RelationFilterTest.php
: Added new test cases for filtering by various relationships, including has-many, belongs-to, belongs-to-many, and has-one relations.tests/TestCase.php
: Configured thepurity.silent
setting tofalse
for better error visibility during testing.