AllowedFields not working #833
Unanswered
sergyu91ma
asked this question in
Q&A
Replies: 2 comments
-
@sergyu91ma Could you provide a curl of your HTTP request? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Versions i use:
"spatie/laravel-query-builder": "5.0.3",
"laravel/framework": "9.37.0",
Code:
$products = QueryBuilder::for(Product::class)->allowedFields( 'importer','name' )->limit(6)->get();
In telescope query for the above code is:
select * from
products
limit 6which selects all fields and returns them and i don't want this of course. I want only importer and name to be selected.
Shouldn't query be (at least this is whats i saw in docs):
SELECT 'importer','name' FROM products LIMIT 6
?I debugged a little and got into this:
`
//File -> vendor/spatie/laravel-query-builder/src/Concerns/AddsFieldsToQuery.php
protected function addRequestedModelFieldsToQuery()
{
$modelTableName = $this->getModel()->getTable();
}`
Beta Was this translation helpful? Give feedback.
All reactions