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 FilterTypeEnum $type;
public string $column; public string $column;
public mixed $filter; public string $filter;
} }

View File

@ -5,6 +5,5 @@ 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';
} }

View File

@ -9,20 +9,17 @@ use JsonMapper;
class Filters class Filters
{ {
public static function rules() public const FILTERS_VALIDATION = [];
{ // 'filters.*.column' => [ 'required', 'string' ],
return [ // 'filters.*.type' => [ 'required', Rule::enum(FilterTypeEnum::class) ],
'filters.*.column' => [ 'required', 'string' ], // 'filters.*.filter' => [ '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[]
@ -57,9 +54,6 @@ 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;

View File

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