Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Sort/SortCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/InteractWithSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
}

Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions tests/Feature/Filters/FilterDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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([
Expand All @@ -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(
Expand Down