Seiten · Laravilt
Query Tool
Let the model search and sort Eloquent records.
Laravilt\AI\Tools\QueryTool runs a LIKE search over the columns you choose and returns the records as arrays.
php
Parameters
Calling model() adds these parameters to the tool definition:
| Parameter | Type | Description |
|---|---|---|
search | string | Search term matched against the searchable columns |
limit | integer | Maximum results (defaults to limit(), 10 if not set) |
orderBy | string | Column to sort by |
orderDirection | string | asc or desc |
Example call from the model:
json
The search is only applied when
searchableColumns()is set.
Methods
| Method | Description |
|---|---|
make(string $name) | Create the tool |
description(string) | Description sent to the model |
model(string $class) | Eloquent model to query |
searchableColumns(array) | Columns used for search |
limit(int) | Default result limit |