1. Go to this page and download the library: Download prolaxu/laravel-intentql library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prolaxu / laravel-intentql example snippets
$result = IntentQL::for(Order::class)
->allowFields(['id', 'agent_id', 'status', 'total', 'created_at'])
->prompt('Show completed orders this month grouped by agent with revenue')
->get();
enum FieldType: string {
case STRING; case INTEGER; case NUMBER; case BOOLEAN;
case DATE; case DATETIME; case JSON; case UUID; case ENUM;
}
IntentQL::for(Order::class)
->allowFields(['status', 'total', 'created_at', 'agent_id'])
->denyFields(['internal_cost', 'deleted_at'])
->prompt('Revenue by agent this month')
->get();
public function customer(): BelongsTo // discovered
public function explode() // never called — no Relation return type
IntentQL::for(Order::class)
->allowRelations(['customer', 'agent', 'items.product'])
->ask('Show completed orders where customer country is Nepal')
->get();
public function intentqlRelations(): array
{
return ['customer', 'agent', 'items.product'];
}
// "Show customers with more than 5 orders"
['relation' => 'orders', 'count_operator' => '>', 'count' => 5]
use Prolaxu\IntentQL\Validation\Contracts\QueryPolicy;
final class TenantQueryPolicy implements QueryPolicy
{
public function authorize(QueryContext $context, QueryDefinition $query): void
{
if (! $context->user?->can('run-reports')) {
throw UnauthorizedQueryException::make('reporting is not enabled for this user.');
}
}
}