CollectionItemBulkActionRequest.php
1 week ago
CollectionItemConditionRequest.php
1 week ago
CollectionItemSingleActionRequest.php
1 month ago
CollectionItemStoreRequest.php
1 week ago
CollectionItemConditionRequest.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Http\Requests\CollectionItem; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use Kirki\Framework\Http\Request; |
| 8 | use Kirki\Framework\Sanitizer; |
| 9 | |
| 10 | use function Kirki\App\ensure_array; |
| 11 | |
| 12 | class CollectionItemConditionRequest extends Request |
| 13 | { |
| 14 | protected function prepare_for_validation() |
| 15 | { |
| 16 | $this->merge([ |
| 17 | 'conditions' => ensure_array($this->conditions), |
| 18 | ]); |
| 19 | } |
| 20 | |
| 21 | public function rules() |
| 22 | { |
| 23 | return [ |
| 24 | 'query' => 'nullable|string', |
| 25 | 'conditions' => 'nullable|array', |
| 26 | 'conditions.*.type' => 'nullable|string', |
| 27 | 'conditions.*.post_type' => 'nullable|string', |
| 28 | 'conditions.*.from' => 'nullable|string', |
| 29 | 'conditions.*.to' => 'nullable|string', |
| 30 | 'conditions.*.category' => 'nullable|string', |
| 31 | 'conditions.*.where' => 'nullable|string', |
| 32 | ]; |
| 33 | } |
| 34 | |
| 35 | public function filters() |
| 36 | { |
| 37 | return [ |
| 38 | 'query' => Sanitizer::TEXT, |
| 39 | 'conditions' => Sanitizer::ARRAY, |
| 40 | 'conditions.*.type' => Sanitizer::TEXT, |
| 41 | 'conditions.*.post_type' => Sanitizer::TEXT, |
| 42 | 'conditions.*.from' => Sanitizer::TEXT, |
| 43 | 'conditions.*.to' => Sanitizer::TEXT, |
| 44 | 'conditions.*.category' => Sanitizer::TEXT, |
| 45 | 'conditions.*.where' => Sanitizer::TEXT, |
| 46 | ]; |
| 47 | } |
| 48 | } |