You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good day @JosephSilber, I got started with bouncer fairly recently and its a really great tool. It has really been helpful.
So lately I've been trying to implement something, I've got this user table and a business table, a single owner can own one or multiple businesses and a single business can be owned by one or multiple owners, so basically the relationship between these two tables is "many to many relationship". So I've got this pivot table that maps businesses to users and in my Business.php and User.php Models I've set up the relationships with the BelongsToMany() method.
Now, my question is, is their anyway for Bouncer to check if a Business model is owned by a given User, given that their is no user_id column on the business table, this would be impossible with something like Bouncer::can($ability, $business), so Is their a way I could do this, by let's say passing the pivot table and the corresponding keys to a method?
I've tried using the Bouncer::ownedVia() method and passed in a callback function that checks if a user owns a business and so on, but I honestly want to know if their is a better way for this.
The text was updated successfully, but these errors were encountered:
So I created a policy class called BusinessPolicy and in it I wrote a method called manage which is the name of the ability pertaining to the business model, now surprisingly this ran fine and I didn't even have to register the policy any where, I read the documentation and I saw nothing about this behavior so I would like to know how this works @JosephSilber
Thank you
Good day @JosephSilber, I got started with bouncer fairly recently and its a really great tool. It has really been helpful.
So lately I've been trying to implement something, I've got this user table and a business table, a single owner can own one or multiple businesses and a single business can be owned by one or multiple owners, so basically the relationship between these two tables is "many to many relationship". So I've got this pivot table that maps businesses to users and in my
Business.php
andUser.php
Models I've set up the relationships with theBelongsToMany()
method.Now, my question is, is their anyway for Bouncer to check if a Business model is owned by a given User, given that their is no
user_id
column on the business table, this would be impossible with something likeBouncer::can($ability, $business)
, so Is their a way I could do this, by let's say passing the pivot table and the corresponding keys to a method?I've tried using the
Bouncer::ownedVia()
method and passed in a callback function that checks if a user owns a business and so on, but I honestly want to know if their is a better way for this.The text was updated successfully, but these errors were encountered: