> ## Documentation Index
> Fetch the complete documentation index at: https://agentictoolbox.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Eloquent

> A tool for executing Eloquent queries on Laravel models.

**class**: `JordanPrice\Toolbox\Tools\Eloquent\EloquentTool`\
**env vars**: `None`\
**source**: [GitHub](https://github.com/jordan-price/toolbox/blob/main/src/Tools/Eloquent/EloquentTool.php)

## Prism Integration

```php theme={null}
use JordanPrice\Toolbox\Tools\Eloquent\EloquentTool;
use EchoLabs\Prism\Prism;
use EchoLabs\Prism\Enums\Provider;
use EchoLabs\Prism\Enums\ToolChoice;

$eloquentTool = new EloquentTool();

$prism = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
    ->withPrompt('Find all active users')
    ->withTools([$eloquentTool])  // Pass the tool instance
    ->toolChoice(ToolChoice::Any);

$response = $prism->generate();
```

## Publish

Optionally, you can publish the configuration file to make modifications:

```bash theme={null}
# Publish just this tool
php artisan toolbox:publish eloquent

# Or publish all tools
php artisan toolbox:publish --all
```

## Methods

### \_\_invoke

Execute Eloquent queries on Laravel models.

```php theme={null}
public function __invoke(string $model, string $operation, array $parameters = []): string
```

#### Parameters

* `model` (string): The model name to query (e.g., User, Post)
* `operation` (string): The operation to perform (e.g., find, where, create)
* `parameters` (array): Parameters for the operation

#### Returns

* `string`: Query result in string format
