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

append new group of conditions #57

Open starking8b opened 1 year ago

starking8b commented 1 year ago

hello , I am trying to append a new group of conditions in the background and in this group, I want to use OR and the relation between this group and the group that was submitted by the user will be AND so this is how it will work group1 which is submitted by a user group 2 which I want to add in the background the relation between group1 and group2 is AND and the conditions in group2 are OR how can I do that? how can I push my conditions in the condition that the customer has been sent?

geo903 commented 10 months ago

use it

            $table = \DB::table('clients');
            $table->select(\DB::raw($request_fields));
            $table->leftjoin('companies', 'clients.company_id', 'companies.id');
            $table->leftjoin('statuses', 'clients.status_id', 'statuses.id');
            $table->where('clients.project_id', '=', $settings['project_id']);

            $table->where(function ($query) use($condition){
                $qbp = new QueryBuilderParser();
                $query = $qbp->parse($condition, $query);
            });

            $clients=$table->get();