You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-v2/content/en/search/advanced-filters.md
+77-3Lines changed: 77 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,22 @@ The frontend has to encode into base64 an array of filters. Each filter contains
89
89
90
90
-`value` - this is optional, and represents the value the advanced filter will as a third argument in the `filter` method
91
91
92
+
## Apply advanced filters via POST Request (Version 9.3.0+)
93
+
94
+
Starting from version 9.3.0, Laravel Restify introduces the ability to apply advanced filters using a POST request. This enhancement simplifies the process of sending complex filter payloads without the need for base64 encoding. Now, you can send the filters directly as JSON in the request body:
Since your class names could change along the way, you can define a `$uriKey` property to your filters, so the frontend will use always the same `key` when applying a filter:
@@ -102,6 +118,64 @@ class ReadyPostsFilter extends AdvancedFilter
102
118
103
119
};
104
120
```
121
+
122
+
### Custom title
123
+
124
+
```php
125
+
class ReadyPostsFilter extends AdvancedFilter
126
+
{
127
+
public static $title = 'Ready to publish posts';
128
+
129
+
//...
130
+
131
+
};
132
+
```
133
+
134
+
### Custom description
135
+
136
+
```php
137
+
class ReadyPostsFilter extends AdvancedFilter
138
+
{
139
+
public static $description = 'Filter all posts that are ready to publish';
140
+
141
+
//...
142
+
143
+
};
144
+
```
145
+
146
+
### Custom meta
147
+
148
+
```php
149
+
class ReadyPostsFilter extends AdvancedFilter
150
+
{
151
+
public function meta(): array
152
+
{
153
+
return [
154
+
'icon' => 'icon',
155
+
'color' => 'red',
156
+
'operators' => [
157
+
'like' => 'Like',
158
+
'eq' => 'Equal',
159
+
]
160
+
];
161
+
}
162
+
};
163
+
```
164
+
165
+
Meta will be rendered key/value in the frontend:
166
+
167
+
```json
168
+
{
169
+
...
170
+
"icon": "icon",
171
+
"color": "red",
172
+
"operators": {
173
+
"like": "Like",
174
+
"eq": "Equal"
175
+
}
176
+
}
177
+
```
178
+
105
179
### Advanced filter value
106
180
107
181
The third argument of the `filter` method is the raw value send by the frontend. Sometimes it might be an array, so you have to get the value using array access:
@@ -392,16 +466,16 @@ In some scenarios, you might want to send additional data beyond the standard ke
In this payload, besides the standard key and value, we are also sending operator and column. The operator specifies the type of SQL operation, and the column specifies the database column to filter.
0 commit comments