-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[WIP] New method linkSync
to update junction tables
#7103
Conversation
Allow junction tables to be updated via the relation. `$model->linkSync('relation', [1, 2, 3, 4]);`
A good method. I often use it. |
Need to write some tests but should support composite keys now. The method can take either an array of foreign key ids or an array of foreign models. e.g. Thoughts? |
Very good, what is needed for integration? |
Tests, docs. |
@samdark the name of the method is ok? I think @alex-code can I change the function signature to add |
No, method name is not OK. Totally confusing. |
@samdark which method name would you prefer? |
Something like |
@Faryshta Please do make changes, I put this up so it can be improved and expanded. |
@samdark I was thinking more along the lines of |
It's not really about relations. It's about junction table... |
Maybe |
Thank you for putting effort in the improvement of the Yii framework. In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests. Could you add these please? Thanks! P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests This is an automated comment, triggered by adding the label |
Won't make it into 2.0. |
Allow junction tables to be updated via the relation.
$model->linkSync('relation', [1, 2, 5, 6]);
This would remove the relation to
3 & 4
and insert new relations to5 & 6
.Based this off
laravel->sync()
from an article I read.This is more of a demo to get some thoughts as it would need updating to support relations more strongly.