Skip to content
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

IndexAction ignores belongsToMany association conditions #651

Open
geoidesic opened this issue Sep 12, 2020 · 0 comments
Open

IndexAction ignores belongsToMany association conditions #651

geoidesic opened this issue Sep 12, 2020 · 0 comments

Comments

@geoidesic
Copy link

geoidesic commented Sep 12, 2020

I’m using friendsofcake/crud I have a pivot table EnquiryContacts which joins Enquiries, Roles and People tables. The EnquiriesTable has a belongsToMany association:

$this->belongsToMany('Clients', ['through' => 'EnquiryContacts', 'className' => 'People', 'conditions' => ['role_id' => 3], 'foreignKey' => 'enquiry_id', 'targetForeignKey' => 'person_id']);

And the PeopleTable has the reverse association:

$this->belongsToMany('ClientEnquiries', ['through' => 'EnquiryContacts', 'className' => 'Enquiries', 'conditions' => ['role_id' => 3], 'foreignKey' => 'person_id', 'targetForeignKey' => 'enquiry_id']);

But results returned by IndexAction will include records with any role_id, instead of just those within the conditions.

Is this expected behaviour or a bug? If expected, how should I go about ensuring a response that takes the conditions of the association into account?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant