Compare commits
2 Commits
eb06d4d033
...
b363bf9fc2
Author | SHA1 | Date |
---|---|---|
b1ek | b363bf9fc2 | |
b1ek | af9762945b |
|
@ -6,5 +6,5 @@ class Filter
|
||||||
{
|
{
|
||||||
public FilterTypeEnum $type;
|
public FilterTypeEnum $type;
|
||||||
public string $column;
|
public string $column;
|
||||||
public string $filter;
|
public mixed $filter;
|
||||||
}
|
}
|
|
@ -5,5 +5,6 @@ namespace App\Facade\Filters;
|
||||||
enum FilterTypeEnum: string
|
enum FilterTypeEnum: string
|
||||||
{
|
{
|
||||||
case Is = 'is';
|
case Is = 'is';
|
||||||
|
case Not = 'not';
|
||||||
case Like = 'like';
|
case Like = 'like';
|
||||||
}
|
}
|
|
@ -9,17 +9,20 @@ use JsonMapper;
|
||||||
class Filters
|
class Filters
|
||||||
{
|
{
|
||||||
|
|
||||||
public const FILTERS_VALIDATION = [];
|
public static function rules()
|
||||||
// 'filters.*.column' => [ 'required', 'string' ],
|
{
|
||||||
// 'filters.*.type' => [ 'required', Rule::enum(FilterTypeEnum::class) ],
|
return [
|
||||||
// 'filters.*.filter' => [ 'required', 'string' ],
|
'filters.*.column' => [ 'required', 'string' ],
|
||||||
|
'filters.*.type' => [ 'required', Rule::enum(FilterTypeEnum::class) ],
|
||||||
|
'filters.*.filter' => [ 'required', 'nullable', 'string' ],
|
||||||
|
|
||||||
// 'orders.*.by' => [ 'required', 'string' ],
|
'orders.*.by' => [ 'required', 'string' ],
|
||||||
// 'orders.*.sort' => [ 'required', Rule::enum(OrderTypeEnum::class) ],
|
'orders.*.sort' => [ 'required', Rule::enum(OrderTypeEnum::class) ],
|
||||||
|
|
||||||
// 'pagination.size' => 'number',
|
'pagination.size' => 'number',
|
||||||
// 'pagination.page' => 'number',
|
'pagination.page' => 'number',
|
||||||
// ];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Filter[]
|
* @var Filter[]
|
||||||
|
@ -54,6 +57,9 @@ class Filters
|
||||||
case FilterTypeEnum::Is:
|
case FilterTypeEnum::Is:
|
||||||
$builder->where($filter->column, $filter->filter);
|
$builder->where($filter->column, $filter->filter);
|
||||||
break;
|
break;
|
||||||
|
case FilterTypeEnum::Not:
|
||||||
|
$builder->whereNot($filter->column, $filter->filter);
|
||||||
|
break;
|
||||||
case FilterTypeEnum::Like:
|
case FilterTypeEnum::Like:
|
||||||
$builder->whereLike($filter->column, $filter->filter);
|
$builder->whereLike($filter->column, $filter->filter);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -7,6 +7,6 @@ class AuthorizedFilterListRequest extends AuthorizedRequest
|
||||||
{
|
{
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return Filters::FILTERS_VALIDATION;
|
return Filters::rules();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue