Comments (9)
@orkempire they aren't, because they're not meant to be used directly. Bouncer uses it behind the scenes.
from bouncer.
i tried using your example in artisan tinker
\Bouncer::allow('admin')->to('create', Order::class);
and it populates the abilities table like so
7 | create | NULL | App\Order | 2016-01-26 04:05:31 | 2016-01-26 04:05:31
so the entity type is NULL , is there a way to pass an entity ID? or model id
is it Ok to be NULL? what is the meaning if the entity id is null and also if it has an ID?
from bouncer.
from bouncer.
so it pertains to the model instance currently taking...
so for example when a user create a order
$order = new Order;
$order->name = 'name';
$order->save();
then ill use it like so to assign an ability
Bouncer::allow('user')->to('edit', $order);
got it.. but how can i use it to show inside my view?
is there a blade directive? like
@can('edit', $order)
<a href="/order/{{ $order->id }}/edit">Edit Post</a>
@endcan
so the 'edit' is the ability and the $order at the can is the instance or the selected id in url...
THanks for your answer
from bouncer.
My understaning now is
this can allow a user to edit all kinds of post id on the Model Post
Bouncer::allow($user)->to('edit', Post::class);
but this one can only edit an specific post....
Bouncer::allow($user)->to('edit', $post);
am i correct?
from bouncer.
from bouncer.
Dont know if im doing it wrong to Authorize a user using this Bounce Method
Authorizing users
$abilities = $user->getAbilities();
----------------------------------------
Silber\Bouncer\Database\Ability {#734
id: 9,
name: "create",
entity_id: 1,
entity_type: "App\Order",
created_at: "2016-01-26 04:23:15",
updated_at: "2016-01-26 04:23:15",
},
-----------------------------------------
Bouncer::allows($ability);
i tried passing id of the ability and get a return false even if i got that abilities
Bouncer::allows(9);
Am i Doing it wrong, nothing says about this on documentation in Authorizing users
from bouncer.
You check abilities by their name, and optionally pass in a model:
$order = Order::find(1);
Bouncer::allows('create', $order);
BTW, this ability of yours doesn't make much sense. Since the order is already created, there's no point in allowing it to be created. But you get the point.
from bouncer.
@JosephSilber sorry for reopening this thread, but where are the entity_id, entity_type mentioned in the docs? Could you please provide a link?
from bouncer.
Related Issues (20)
- setup with filament not working HOT 1
- No migrations when upgrading from 1.0.0-rc.3 HOT 1
- Question: How can I get certain model Instance's users with ability 'update' ? HOT 1
- Can helper returning true after removing role from the user HOT 2
- error foreign keys with Planetscale HOT 3
- How To Add / Remove Roles Temporarily (for current request only) ? HOT 5
- [HELP] Extend Ability HOT 1
- Migration issues using Multitenancy System HOT 8
- Get all users with all their roles HOT 2
- scope is not reset between tests HOT 5
- Fine grade check delete ability
- Adjust connection for can() gate
- How to get owns and check is owned HOT 1
- Is it possible to keep all abilities hardcoded instead of abilities table HOT 1
- Permission on belongToMany relation of entity HOT 4
- enforceMorphMap support
- Documentation is extremely time consuming and confusing
- UUID guide please
- Add Granted By
- Is there any way to refresh() cache for all tenants
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bouncer.