Comments (2)
@lachlanhickey, kind of.
It depends on what exactly you are trying to achieve, but you can usually do something along the lines of this:
class Author extends \Illuminate\Database\Eloquent\Model {
// ....
}
$author = new Author();
// https://github.com/illuminate/database/blob/1e4476bac20b5c5e558efa02c4fb0ad46efd8013/Eloquent/Builder.php#L1353-L1361
$table = $author->getQuery();
$qbp = new QueryBuilderParser(
// provide here a list of allowable rows from the query builder.
// NOTE: if a row is listed here, you will be able to create limits on that row from QBP.
array( 'name', 'email' )
);
$query = $qbp->parse($input['querybuilder'], $table);
from querybuilderparser.
For future reference.
If someone wants to use the accessors or model relations of the result you could hydrate the results.
$table = DB::table('models')
// join the relation(s)
->leftJoin('relations', 'relations.id', '=', 'other_table.relation_id');
$qbp = new QueryBuilderParser(
// provide here a list of allowable rows from the query builder.
// NOTE: if a row is listed here, you will be able to create limits on that row from QBP.
array( 'name', 'email' )
);
$query = $qbp->parse($input['querybuilder'], $table);
$rows = $query->get();
$models = Model::hydrate($rows->all());
Then as usual
foreach($models as $model)
{
echo $model->accessor;
echo $model->relations->foo;
}
from querybuilderparser.
Related Issues (20)
- installation failure
- Example with DataTables HOT 2
- JoinSupportingQueryBuilderParser HOT 1
- mongoDB aggregation HOT 2
- Better handling of not_equal operator HOT 1
- Laravel 9 compatibility HOT 2
- New tag that supports Laravel 9 HOT 1
- SQL Injection Bypass HOT 1
- append new group of conditions HOT 1
- contains like -> ilike
- Use Model instead of DB? HOT 1
- How to Use Model instead of using DB?
- Kindly update to laravel 10 HOT 1
- How to join a distant table with one intermediate table HOT 1
- Code in View HOT 1
- Method makeQuery in the class JoinSupportingQueryBuilderParser in v2.0.0 HOT 2
- Nested rules bug HOT 3
- Abandoned package?
- Error. Undefined property: stdClass::$field
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from querybuilderparser.