Compare commits

..

No commits in common. "b363bf9fc276af9a77d2c94e435d232afc940b62" and "eb06d4d033c85e721a377d4b503649e81450a72f" have entirely different histories.

4 changed files with 11 additions and 18 deletions

View File

@ -6,5 +6,5 @@ class Filter
{
public FilterTypeEnum $type;
public string $column;
public mixed $filter;
public string $filter;
}

View File

@ -5,6 +5,5 @@ namespace App\Facade\Filters;
enum FilterTypeEnum: string
{
case Is = 'is';
case Not = 'not';
case Like = 'like';
}

View File

@ -9,20 +9,17 @@ use JsonMapper;
class Filters
{
public static function rules()
{
return [
'filters.*.column' => [ 'required', 'string' ],
'filters.*.type' => [ 'required', Rule::enum(FilterTypeEnum::class) ],
'filters.*.filter' => [ 'required', 'nullable', 'string' ],
public const FILTERS_VALIDATION = [];
// 'filters.*.column' => [ 'required', 'string' ],
// 'filters.*.type' => [ 'required', Rule::enum(FilterTypeEnum::class) ],
// 'filters.*.filter' => [ 'required', 'string' ],
'orders.*.by' => [ 'required', 'string' ],
'orders.*.sort' => [ 'required', Rule::enum(OrderTypeEnum::class) ],
// 'orders.*.by' => [ 'required', 'string' ],
// 'orders.*.sort' => [ 'required', Rule::enum(OrderTypeEnum::class) ],
'pagination.size' => 'number',
'pagination.page' => 'number',
];
}
// 'pagination.size' => 'number',
// 'pagination.page' => 'number',
// ];
/**
* @var Filter[]
@ -57,9 +54,6 @@ class Filters
case FilterTypeEnum::Is:
$builder->where($filter->column, $filter->filter);
break;
case FilterTypeEnum::Not:
$builder->whereNot($filter->column, $filter->filter);
break;
case FilterTypeEnum::Like:
$builder->whereLike($filter->column, $filter->filter);
break;

View File

@ -7,6 +7,6 @@ class AuthorizedFilterListRequest extends AuthorizedRequest
{
public function rules()
{
return Filters::rules();
return Filters::FILTERS_VALIDATION;
}
}