timgws / QueryBuilderParser

A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.
MIT License
159 stars 65 forks source link

Custom bindings for fields #32

Open curunoir opened 6 years ago

curunoir commented 6 years ago

Hello, it would be helpful to be able to create bindings for fields similarly at what is done for JoinSupportingQueryBuilderParser. If I store some values within json columns I can't use the parser to filter on these fields easily. Something like that could be usefull :

$bindingsFields = array(
        'myjsonfield1' => array(
            'from_table'      => 'table1',
            'from_col'        => 'json_col',
            'json_path'        => 'json_fields->myjsonfield1->myjsonfield1->value' // should be optional if field is not within a json column
        ),
geo903 commented 12 months ago

you can access json fields like this

{
  "condition": "OR",
  "rules": [
    {
      "id": "firstname",
      "field": "fields->first_name",
      "type": "string",
      "input": "text",
      "operator": "equal",
      "value": "hhh"
    },
    {
      "id": "tel",
      "field": "fields->tel",
      "type": "string",
      "input": "text",
      "operator": "equal",
      "value": "77"
    }
  ],
  "valid": true
}