- How do I install QueryBuilderParser in a Laravel 12/13 project?
- Run `composer require timgws/query-builder-parser@^2.2` to install the package. No additional Laravel-specific setup is required beyond initializing the parser with allowed fields. The package is explicitly tested for Laravel 12/13 compatibility.
- Can I use this package with jQuery QueryBuilder v1.6+?
- Yes, QueryBuilderParser is designed to work with jQuery QueryBuilder v1.6 and later. The package translates the JSON rules from the frontend directly into Laravel query constraints, ensuring compatibility with the latest frontend versions.
- What if my table has 50+ columns? How do I manage rule granularity?
- Use the whitelist feature to explicitly define allowed fields during parser initialization. For complex schemas, consider grouping related fields into nested rules or custom rule classes. The package supports dynamic rule validation but requires explicit configuration for large datasets.
- Does QueryBuilderParser support MongoDB queries?
- Yes, the package integrates with `jenssegers/mongodb` to generate MongoDB queries (e.g., `$regex`, `$and` operators) from jQuery QueryBuilder rules. Initialize the parser with a MongoDB collection instead of a SQL table to enable this functionality.
- How do I integrate this with Laravel DataTables?
- Use jQuery QueryBuilder alongside DataTables to capture frontend filter rules. Pass the parsed JSON to QueryBuilderParser, which generates the SQL for DataTables’ server-side processing. The package handles pagination, sorting, and filtering dynamically.
- Are there performance concerns with nested or complex rules?
- Complex nested rules may generate verbose SQL, but Laravel 12/13’s query builder optimizations (e.g., improved `where` clause handling) mitigate this. Test with your specific dataset to ensure query performance meets requirements, especially for large tables.
- What Laravel versions does this package officially support?
- QueryBuilderParser is officially tested and compatible with Laravel 12 and 13. While it works with older versions (e.g., 5.5+), new features may require updates. Always check the package’s release notes for version-specific changes.
- How do I handle unsupported jQuery QueryBuilder features?
- The package provides a fallback mechanism for unsupported features by validating rules against a whitelist. For custom logic, extend the parser with your own rule classes or override default behavior. Unsupported features will throw exceptions or skip parsing.
- Can I leverage Laravel 12/13’s new query builder features (e.g., `whereJsonContains`)?
- Yes, the package is designed to work with Laravel 12/13’s updated query builder. For advanced features like `whereJsonContains`, ensure your custom rules or whitelisted fields align with the new syntax. Test thoroughly to confirm compatibility.
- What security risks should I be aware of when using this package?
- The primary risk is SQL injection if dynamic column names bypass the whitelist. Always validate and restrict allowed fields during parser initialization. For MongoDB, ensure regex patterns are sanitized to prevent NoSQL injection.