Skip to content

Commit 23d5a9f

Browse files
committed
Update README.md
1 parent b45139f commit 23d5a9f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,34 @@ Instant Fields will try to auto-fill the select2 input after creating a new entr
254254
]
255255
```
256256

257+
You can also pass an array of `attributes` instead of a single attribute:
258+
```
259+
'on_the_fly' => [
260+
'entity' => 'entity',
261+
'attributes' => [
262+
'company',
263+
'contact_name',
264+
'address',
265+
]
266+
]
267+
```
268+
In order for this to work properly on multiple columns, you should implement a custom search logic for the field.
269+
270+
Search logic example:
271+
```
272+
'search_logic' => function ($query, $searchTerm) {
273+
return $query->where(function ($q) use ($searchTerm) {
274+
collect(explode(' ', $searchTerm))->each(function ($searchTermPart) use ($q) {
275+
$q->where(function ($sq) use ($searchTermPart) {
276+
$sq->where('company', 'LIKE', '%' . $searchTermPart . '%')
277+
->orWhere('contact_name', 'LIKE', '%' . $searchTermPart . '%')
278+
->orWhereRaw('LOWER(JSON_EXTRACT(address, "$.postcode")) LIKE \'"' . strtolower($searchTermPart) . '%\'');
279+
});
280+
});
281+
})->orderBy('name');
282+
```
283+
284+
257285
### Passing current field values to foreign `EntityCrudController`
258286

259287
Sometimes you will need current values to be used for the creation of an foreign entity. You may define `serialize` with the IDs of the fields you need in the store request:

0 commit comments

Comments
 (0)