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

How to get owns and check is owned #648

Open
bilginnet opened this issue Apr 24, 2024 · 1 comment
Open

How to get owns and check is owned #648

bilginnet opened this issue Apr 24, 2024 · 1 comment

Comments

@bilginnet
Copy link

In laravel 11 I am assigning ownership to an organization like below.

$organization = Organization::create(['name' => 'Test Org']);
Bouncer::allow($user)->toOwn($organization);

Question 1: How can I see which organizations I have ownership rights after logging in.
Ex: $user->owns()

Question 2: How do I check if the user has ownership rights on any organization after login?
Ex: $user->isOwnedFor($organization)

@EriBloo
Copy link

EriBloo commented May 20, 2024

Since ownership is handled by key on the Organization model, you could just use relation for this. Ownership checks if Organization has user_id (by default) with value of authenticated user. If so, that user owns this model.

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

2 participants