Closed paul-lestyo closed 1 year ago
Hey, can you share the full request URL and what your QueryBuilder
code looks like in your controller, please? It'll be easier to identify whether this is a bug or a misunderstanding with the package :)
Hello, I would like to respond to this issue because I have the same problem. For example : products?fields[products]=id,name,brand_id&include=brand&sort=-products.id&paginate=15&filter[brand.name]=Power here: fields[products], products should be the name of the table, not the relationship, which is a shame. Similarly, &sort=-products.id, the sorting must be done with the name of the table, and not the relationship, whereas it would be simpler with the name of the relationship. On the other hand, &filter[brand.name] is done with the name of the relationship... The PR https://github.com/spatie/laravel-query-builder/pull/794 fixes these little problems. See line 52 of the AddsFieldsToQuery feature ;)
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
in case, i have model Event::class who have column assign_by and assign_to refer Staff::class. I create function relations like this![image](https://user-images.githubusercontent.com/51690314/216535057-795073d6-856c-4f6e-a44f-d74e044a2a9e.png)
then when I try allowedFields column staff.id its didn't work, but when I use fileds[assign_by] that is not referred to any table name.
I try to dump variable $relation and $table in function getRequestedFieldsForRelatedTable() and get these result![image](https://user-images.githubusercontent.com/51690314/216536390-c65b2e72-f720-4a8f-87c8-68245a1081ed.png)
is it a bug or i am having mistake in my code? Thx