diff --git a/src/Sort/SortCollection.php b/src/Sort/SortCollection.php index 8b4b94337..7333bc7f2 100644 --- a/src/Sort/SortCollection.php +++ b/src/Sort/SortCollection.php @@ -58,7 +58,6 @@ public function hydrateDefinition(Repository $repository): SortCollection $definition = Arr::get($repository::getOrderByFields(), $filter->getColumn()); - if (is_callable($definition)) { return $filter->usingClosure($definition); } diff --git a/src/Traits/InteractWithSearch.php b/src/Traits/InteractWithSearch.php index 23b6d3890..3221931c8 100644 --- a/src/Traits/InteractWithSearch.php +++ b/src/Traits/InteractWithSearch.php @@ -117,7 +117,7 @@ public static function collectFilters($type): Collection SortableFilter::uriKey() => SortableFilter::class, ])->get($type); - if (!is_subclass_of($base, Filter::class)) { + if (! is_subclass_of($base, Filter::class)) { return collect([]); } @@ -132,7 +132,7 @@ public static function collectFilters($type): Collection } return $type instanceof Filter - ? tap($type, fn($filter) => $filter->column = $filter->column ?? $column) + ? tap($type, fn ($filter) => $filter->column = $filter->column ?? $column) : tap(new $base, function ($filter) use ($column, $type) { $filter->type = $type; $filter->column = $column; diff --git a/tests/Feature/Filters/FilterDefinitionTest.php b/tests/Feature/Filters/FilterDefinitionTest.php index f6d905919..09e62c2df 100644 --- a/tests/Feature/Filters/FilterDefinitionTest.php +++ b/tests/Feature/Filters/FilterDefinitionTest.php @@ -6,13 +6,11 @@ use Binaryk\LaravelRestify\Filters\MatchFilter; use Binaryk\LaravelRestify\Filters\SearchableFilter; use Binaryk\LaravelRestify\Filters\SortableFilter; -use Binaryk\LaravelRestify\Http\Requests\RestifyRequest; use Binaryk\LaravelRestify\Tests\Fixtures\Post\Post; use Binaryk\LaravelRestify\Tests\Fixtures\Post\PostRepository; use Binaryk\LaravelRestify\Tests\Fixtures\User\User; use Binaryk\LaravelRestify\Tests\Fixtures\User\UserRepository; use Binaryk\LaravelRestify\Tests\IntegrationTest; -use Illuminate\Database\Eloquent\Builder; class FilterDefinitionTest extends IntegrationTest { @@ -74,7 +72,7 @@ public function test_can_filter_using_belongs_to_field() PostRepository::$sort = [ 'users.attributes.name' => SortableFilter::make()->setColumn('users.name')->usingBelongsTo( BelongsTo::make('user', 'user', UserRepository::class), - ) + ), ]; factory(Post::class)->create([ @@ -91,7 +89,7 @@ public function test_can_filter_using_belongs_to_field() $json = $this ->withoutExceptionHandling() - ->getJson(PostRepository::uriKey() . '?related=user&sort=-users.attributes.name') + ->getJson(PostRepository::uriKey().'?related=user&sort=-users.attributes.name') ->json(); $this->assertSame(