Skip to content

Commit d374253

Browse files
authored
Merge pull request #51 from tailflow/next
Release v1.2.4
2 parents 8cb6ec1 + 43eb296 commit d374253

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/Drivers/Standard/ParamsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function validateFilters(Request $request): void
4949
'filters.*.type' => ['sometimes', 'in:and,or'],
5050
'filters.*.field' => ['required_with:filters', 'regex:/^[\w.]+$/', new WhitelistedField($this->filterableBy)],
5151
'filters.*.operator' => ['required_with:filters', 'in:<,<=,>,>=,=,!=,like,not like,in,not in'],
52-
'filters.*.value' => ['required_with:filters', 'nullable']
52+
'filters.*.value' => ['present', 'nullable']
5353
])->validate();
5454
}
5555

tests/Feature/StandardIndexFilteringOperationsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Orion\Tests\Feature;
44

5+
use Carbon\Carbon;
56
use Illuminate\Support\Facades\Gate;
67
use Orion\Tests\Fixtures\App\Models\Company;
78
use Orion\Tests\Fixtures\App\Models\Post;
@@ -319,4 +320,24 @@ public function getting_a_list_of_resources_filtered_by_relation_field_with_wild
319320
$this->makePaginator([$matchingTeam], 'teams/search')
320321
);
321322
}
323+
324+
/** @test */
325+
public function getting_a_list_of_resources_filtered_by_model_field_using_nullable_value(): void
326+
{
327+
$matchingPost = factory(Post::class)->create(['publish_at' => null])->fresh();
328+
factory(Post::class)->create(['publish_at' => Carbon::now()])->fresh();
329+
330+
Gate::policy(Post::class, GreenPolicy::class);
331+
332+
$response = $this->post('/api/posts/search', [
333+
'filters' => [
334+
['field' => 'publish_at', 'operator' => '=', 'value' => null]
335+
]
336+
]);
337+
338+
$this->assertResourcesPaginated(
339+
$response,
340+
$this->makePaginator([$matchingPost], 'posts/search')
341+
);
342+
}
322343
}

tests/Fixtures/app/Http/Controllers/PostsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function sortableBy() : array
3232

3333
protected function filterableBy() : array
3434
{
35-
return ['title', 'position', 'user.name'];
35+
return ['title', 'position', 'publish_at', 'user.name'];
3636
}
3737

3838
protected function searchableBy() : array

0 commit comments

Comments
 (0)