Giter Club home page Giter Club logo

Comments (7)

romanbican avatar romanbican commented on July 29, 2024

Is this what you want? https://github.com/romanbican/roles#entity-check

from roles.

WillyReyno avatar WillyReyno commented on July 29, 2024

I don't really understand where I must put the $user->attachPermission ? Is it on creating an article for example ?

from roles.

romanbican avatar romanbican commented on July 29, 2024

Well, you must have something like admin panel where you can attach roles and permissions.

from roles.

WillyReyno avatar WillyReyno commented on July 29, 2024

Okay, I made it work for articles.

But I still can't use it on the user profile.

I put this in my seeders :

permissiontableseeder2

And in my view I put :

blade

$user being the user whose profile is displayed.

I tried logging in with an user, and whatever the profile I'm looking (my own or someone else's), the "test" is showing. I just want it to be displayed on my own profile page.

By the way, thank you for helping me, I'm not really at ease with Laravel for the moment.

from roles.

romanbican avatar romanbican commented on July 29, 2024

So, now I understand. I'll explain you.

If you want a user to edit all articles, give him permission edit.articles. Then he can edit all articles even if he didn't create them. If you don't give him permission, allowed() method will check if he created that article. But it is working only with belongsTo relationship.

If you want to check if the logged user can edit user he is looking at, you can make simple if statement like this:

@if(Auth::user()->id === $user->id)
   //
@endif

There's no need to check for permissions unless you have a admin which can edit all users.

Hope it helps.

There is a allowed method, have a look:

/**
 * Check if the user is allowed to manipulate with entity.
 *
 * @param string $providedPermission
 * @param object $entity
 * @param bool $owner
 * @param string $ownerColumn
 * @return bool
*/
public function allowed($providedPermission, $entity, $owner = true, $ownerColumn = 'user_id');

from roles.

rusjoan avatar rusjoan commented on July 29, 2024

As I have understood, permissions that attached to role doesn't provide entity check except such ones that attached directly to user. Am I right?

from roles.

romanbican avatar romanbican commented on July 29, 2024

No. They can be attached to role.

from roles.

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.