-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relation not working #16
Comments
Remove the parts of the query you dont need, like permissions and roles |
I need the roles, but also in this case I have I want the users with their state name, but returns all the data, the where in the "include" is not working, I am using laravel 5.5 can it be the issue? |
I tried with laravel 5.2 and the same error, $exampleArrayQuery = [
is returning "select |
The
|
$exampleArrayQuery = [ Call to undefined method Illuminate\Database\Query\Builder::state() User model State Model public function users(){ |
The where goes on the base:
|
ok thank you, now the filter is working with this $exampleArrayQuery = [ It display the users only in "California" but does not have the state data, it shows the query that returns is: select |
Do you have a working project example? I was not able to let it work :( |
I use it on many private projects of mine but I dont have any public. I dont know what your problem may be, could you try writing the same query using Laravel's query builder and see if it works as you want? |
Ok I did other test, I have users that have many posts $exampleArrayQuery = [ $query = User::query(); should be the same as: User::with('posts')->where('name', '=', 'GreatAdmin')->get(); Right?, but the second one returns the user "GreatAdmin" with his posts, but the first one only the user info and relations empty :/ relations: array:1 [▼ |
Now I see the error, there is a conflict with ->select and ->with based on some posts like this I let it work removing the "fields" on the relation, event the where in the relation is working now $exampleArrayQuery = [ It returned the user with all posts data, the problem will be if I only want some fields of that posts |
Oh, good to know, I never ran into this problem cause I rarely use As the Stackoverflow answers says, a workaround like this should work (note the
|
Hi!, I am running your example with the User model and it is not working, I am running
$exampleArrayQuery = [
'fields' => ['id', 'first_name', 'created_at'],
'order' => 'first_name',
'include' => [
'permissions' => true,
'roles' => [
'where' => [
'name' => 'xxx',
],
'fields' => ['id', 'name'],
'order' => 'name DESC',
],
],
'offset' => 5,
'limit' => 15,
];
and always return the same data, I dont have a role with name "xxx" and also the data returned does not have the "roles" info
The text was updated successfully, but these errors were encountered: