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
814 stars 72 forks source link

Unable to specifiy foreign key column name #100

Closed chazzka closed 5 months ago

chazzka commented 1 year ago

The based-upon package laravel-follow deals with different config attribute for foreign key (changing the default "user_id").

This is useful when using different Model for auth (instead of the default User)

This package unfortunately omits it, making different foreign key impossible to set, eventually causing errors in autogenerated queries. (interactions.foreign_key_name).

Now, if user wants a different foreign key naming, he can directly specify in migration, but later generated scripts will still respect the previous configuration.

Please consider adding similar configuration as in previous package on this line

mkwsra commented 1 year ago

Hey Chazzka, thanks for your input, and yes for sure! this is something fairly easy to implement, I will take a look at it in the upcoming weeks.

Thanks for pointing it out and for your explanation 🙌

adriallongarriu commented 5 months ago

Hello @mkwsra, i was facing this error. With the documentation I thought that just by adding the traits CanXXX like CanLike it will work with any model.

For now i directly specify the column name in migration alredy created.

mkwsra commented 5 months ago

Hi Adrià, thanks for pointing this out, we have to do something about this (someone of us)

adriallongarriu commented 5 months ago

@mkwsra later i will make a PR modifying the migration and the function isRelationExists that uses 'user_id' to use the variables in config file.

The option to use two morphTo relation will be cool but will require more time and will introduce breaking changes.