Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Dec 10, 2021
1 parent fddd0eb commit ea85f92
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function validate(): bool

/**
* Get if column is acceptable for filter.
*
* @param array<int, string> $only
* @param array<int, string> $except
*/
public function accepted(array $only = [], array $except = []): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/ConditionallySearchingWildcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait ConditionallySearchingWildcard
/**
* Set wildcard search variants.
*
* @param array $searchVariants
* @param array<int, string> $searchVariants
*
* @return $this
*/
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Filter
* Apply search queries.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Contracts/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ public function getValue(): string;

/**
* Get searchable strings.
*
* @return array<int, string>
*/
public function all(): array;

/**
* Handle resolving keyword for filter.
*
* @return array<int, string>
*/
public function handle(Filter $filter): array;
}
1 change: 1 addition & 0 deletions src/Filters/FieldSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct($column)
* Apply generic field search queries.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand Down
1 change: 1 addition & 0 deletions src/Filters/JsonFieldSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct($path)
* Apply JSON field search queries.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Filters/MorphRelationSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MorphRelationSearch extends SearchFilter implements RequiresEloquent
* Construct new Morph Related Search.
*
* @param \Illuminate\Database\Query\Expression|string $column
* @param array<int, string> $types
*/
public function __construct(string $relation, $column, array $types = [])
{
Expand All @@ -44,6 +45,7 @@ public function __construct(string $relation, $column, array $types = [])
* Apply relation search queries.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder
*/
Expand Down
1 change: 1 addition & 0 deletions src/Filters/PrimaryKeySearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(?int $maxPrimaryKeySize = null)
* Apply primary key field search queries.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder
*/
Expand Down
1 change: 1 addition & 0 deletions src/Filters/RelationSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct(string $relation, $column)
* Apply relation search queries.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array<int, string> $keywords
*
* @return \Illuminate\Database\Eloquent\Builder
*/
Expand Down
8 changes: 7 additions & 1 deletion src/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Keyword implements KeywordContract
/**
* List default search variations.
*
* @var string[]
* @var array<int, string>
*/
public static $defaultSearchVariations = ['{keyword}', '{keyword}%', '%{keyword}', '%{keyword}%'];

Expand Down Expand Up @@ -53,6 +53,8 @@ public function validate(): bool

/**
* Get searchable strings.
*
* @return array<int, string>
*/
public function all(): array
{
Expand All @@ -67,6 +69,8 @@ public function all(): array

/**
* Handle resolving keyword for filter.
*
* @return array<int, string>
*/
public function handle(Contracts\Filter\Filter $filter): array
{
Expand Down Expand Up @@ -94,6 +98,8 @@ public function __toString()

/**
* Convert basic string to searchable result.
*
* @return array<int, string>
*/
public static function searchable(
string $text,
Expand Down
6 changes: 4 additions & 2 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Searchable

/**
* Construct a new Search Query.
*
* @param array<int, string|\Laravie\QueryFilter\Contracts\Filter> $fields
*/
public function __construct(?string $keyword, array $fields = [])
{
Expand Down Expand Up @@ -66,8 +68,8 @@ public function apply($query)
$likeOperator = like_operator(connection_type($query));

/**
* @var \Illuminate\Support\Collection $filters
* @var \Illuminate\Support\Collection $fields
* @var \Illuminate\Support\Collection<int, \Laravie\QueryFilter\Contracts\Filter> $filters
* @var \Illuminate\Support\Collection<int, string> $fields
*/
[$filters, $fields] = Collection::make($this->fields)->partition(static function ($field) {
return $field instanceof Contracts\Filter\Filter;
Expand Down
7 changes: 5 additions & 2 deletions src/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class Taxonomy
/**
* Taxonomy columns.
*
* @var array
* @var array<int, string|\Laravie\QueryFilter\Contracts\Filter>
*/
protected $fields = [];

/**
* Taxonomy rules.
*
* @var array<string,callable>
* @var array<string, \Closure|callable>
*/
protected $rules = [];

Expand All @@ -33,6 +33,9 @@ class Taxonomy

/**
* Construct a new Matches Query.
*
* @param array<string, \Closure|callable> $rules
* @param array<int, string|\Laravie\QueryFilter\Contracts\Filter> $fields
*/
public function __construct(?string $terms, array $rules = [], array $fields = [])
{
Expand Down
8 changes: 7 additions & 1 deletion src/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class Terms implements Countable
/**
* Tagged conditions.
*
* @var array
* @var array<int, string>
*/
protected $tagged = [];

/**
* Construct a new Condition value object.
*
* @param array<int, string> $tagged
*/
public function __construct(string $basic, array $tagged)
{
Expand All @@ -34,6 +36,8 @@ public function __construct(string $basic, array $tagged)
/**
* Parse rules from keyword.
*
* @param array<int, string> $rules
*
* @return static
*/
public static function parse(string $term, array $rules)
Expand Down Expand Up @@ -74,6 +78,8 @@ public function basic(): string

/**
* Get tagged conditions.
*
* @return array<int, string>
*/
public function tagged(): array
{
Expand Down

0 comments on commit ea85f92

Please sign in to comment.