Giter Site home page Giter Site logo

Comments (9)

JosephSilber avatar JosephSilber commented on August 16, 2024 1

@orkempire they aren't, because they're not meant to be used directly. Bouncer uses it behind the scenes.

from bouncer.

masterpowers avatar masterpowers commented on August 16, 2024

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.

JosephSilber avatar JosephSilber commented on August 16, 2024

from bouncer.

masterpowers avatar masterpowers commented on August 16, 2024

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.

masterpowers avatar masterpowers commented on August 16, 2024

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.

JosephSilber avatar JosephSilber commented on August 16, 2024

from bouncer.

masterpowers avatar masterpowers commented on August 16, 2024

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.

JosephSilber avatar JosephSilber commented on August 16, 2024

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.

orkempire avatar orkempire commented on August 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.