Giter VIP home page Giter VIP logo

Comments (2)

parallels999 avatar parallels999 commented on June 2, 2024

It seems to me that you made some mistake in the configuration. Upload a demo repo with the code showing the problem
https://spatie.be/laravel-permission/creating-a-demo-app

from laravel-permission.

drbyte avatar drbyte commented on June 2, 2024
  1. The "there is no role with ID x" error is thrown by Role::findById(), which is called from getStoredRole(), which is called by collectRoles(), which is called by assignRole().

  2. Your posted assignRole() call looks strange. Why are you passing a nested array?

When reformatting your posted code of:
$userOrgManager->assignRole([$roleOrgManager->id => ['organization_id' => $organization->id]]);
it looks like this:

$userOrgManager->assignRole([
    $roleOrgManager->id => [
        'organization_id' => $organization->id
        ]
    ]);

That's not the kind of array that assignRole() accepts. assignRole() accepts a one-dimensional array of role ids or role objects/records or role names.

  1. It should never be looking for a role with an ID of uuid (or org_uuid) ... that's part of the schema, not a valid record id. (If you were giving a role name of uuid, then perhaps "uuid" might be acceptable, but if it gave an error related to such a name, then it would say that it couldn't find a role with that name, not "ID".)
    Thus, as parallels999 mentioned, something is wrong in your code or your configuration.
    We need to see your complete code related to this. As mentioned, please create a fresh repository for a basic app which recreates this exact problem.

from laravel-permission.

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.