You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 = newAuthor();
// https://github.com/illuminate/database/blob/1e4476bac20b5c5e558efa02c4fb0ad46efd8013/Eloquent/Builder.php#L1353-L1361$table = $author->getQuery();
$qbp = newQueryBuilderParser(
// 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);
timgws
changed the title
Eloquent
Using with Eloquent, not just Laravel's QueryBuilder
Mar 9, 2021
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 = newQueryBuilderParser(
// 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());
Just wondering if collections are supported with this package? Or only DB:: queries?
The text was updated successfully, but these errors were encountered: