multicaret / laravel-acquaintances

This package gives Eloquent models the ability to manage friendships (with groups), followships along with Likes, favorites..etc.
https://laravel-news.com/manage-friendships-likes-and-more-with-the-acquaintances-laravel-package
MIT License
808 stars 72 forks source link

Solve isRelationExists causing potential ambiguous errors by not spec… #89

Closed midblep closed 1 year ago

midblep commented 1 year ago

On a project I'm working on that I use this package for, I have some complicated global scope needs. Some of those scopes involve joins, and the best way I found to prevent those causing ambiguous field errors was by making sure all where statements are fully qualified by overriding Laravel's builder class.

However this packages was giving me SQL errors about subject_id and user_id being ambiguous in some instances, like when using hasLiked and hasSubscribed on the user model.

Regardless of the motivation, I think packages should fully qualify their field names in queries to prevent possible errors. Considering the table name for interactions is already part of the config, this was an easy fix and instead of overriding the classes myself I thought I'd put out a PR.

This is my first time ever committing a proposed fix to a public repository, please let me know if I did anything wrong. Thanks for the amazing package.

midblep commented 1 year ago

Any news or insight on this?

mkwsra commented 1 year ago

Hey Mid 👋, thanks for your contribution and you did great! I will handle the change-log and releasing a new version so you can hit composer update 🫡 Thanks for your PR buddy, it's appreciated!

mkwsra commented 1 year ago

I'm so sorry for not merging this earlier I just noticed it along with another PR, sorry man!

midblep commented 1 year ago

No problem, thanks for adding it into a release! I had already overwritten some files from the package to achieve the same result, but now I can get rid of those and it'll all be clean and tidy again. :)