Git Product home page Git Product logo

cakephp-permission's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working on Nanjing
  • ๐Ÿ‘€ Iโ€™m interested in PHP & Java & Go
  • ๐ŸŒฑ Iโ€™m currently learning Typescript

Slince's GitHub stats Top Langs

Achievements

๐Ÿ’ป Languages

PHP Java Go Javascript

cakephp-permission's People

Contributors

slince avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cakephp-permission's Issues

You can't have an association of the same name with a different target "className" option anywhere in your app

I have done everything as written in the doc and I have no problem until I try to give a permission to a specific role.

 $roleObj = Role::find($role->name);
 $roleObj->givePermission($addPermission);

Here is what I got dump&dying $roleObj before the second line of the previous snippet.

object(Slince\CakePermission\Model\Entity\Role)#239 (13) {
  ["id"]=>
  int(6)
  ["name"]=>
  string(5) "Admin"
  ["slug"]=>
  string(5) "Admin"
  ["created"]=>
  object(Cake\I18n\Time)#258 (3) {
    ["time"]=>
    string(25) "2018-08-22T11:41:28+00:00"
    ["timezone"]=>
    string(3) "UTC"
    ["fixedNowTime"]=>
    bool(false)
  }
  ["modified"]=>
  string(15) "22/08/18, 11:41"
  ["[new]"]=>
  bool(false)
  ["[accessible]"]=>
  array(2) {
    ["id"]=>
    bool(false)
    ["*"]=>
    bool(true)
  }
  ["[dirty]"]=>
  array(0) {
  }
  ["[original]"]=>
  array(0) {
  }
  ["[virtual]"]=>
  array(0) {
  }
  ["[errors]"]=>
  array(0) {
  }
  ["[invalid]"]=>
  array(0) {
  }
  ["[repository]"]=>
  string(16) "_PermissionRoles"
}

When I run the givePermission command I see this error

Slince\CakePermission\Model\Table\RolesTable association "Permissions" of type "manyToMany" to "App\Model\Table\PermissionsTable" doesn't match the expected class "Slince\CakePermission\Model\Table\PermissionsTable". You can't have an association of the same name with a different target "className" option anywhere in your app.

I have looked for solutions but there is nothing relevant of this case.

Have I missed some step during the configuration?
Here are the relations I am try to use without success

$this->belongsToMany('Permissions', [
            'targetTable' => 'Slince\CakePermission\Model\Table\Permissions',
            'className' => 'Slince\CakePermission\Model\Table\Permissions',
            'foreignKey' => 'role_id',
            'targetForeignKey' => 'permission_id',
            'joinTable' => 'roles_permissions',
            'saveStrategy' => 'append'
 ]);
$this->belongsToMany('Roles', [
            'targetTable' => 'Slince\CakePermission\Model\Table\Roles',
            'className' => 'Slince\CakePermission\Model\Table\Roles',
            'foreignKey' => 'permission_id',
            'targetForeignKey' => 'role_id',
            'joinTable' => 'roles_permissions',
            'saveStrategy' => 'append'
]);

You can't have an association of the same name with a different target "className" option anywhere in your app.

I am getting this error when login, after refresh the browser the error is gone.
I already checked (just in case), my models, and I only have one "Roles" association.

App\Model\Table\UsersTable association "Roles" of type "manyToMany" to "Slince\CakePermission\Model\Table\RolesTable" doesn't match the expected class "App\Model\Table\RolesTable". 
You can't have an association of the same name with a different target "className" option anywhere in your app.

cake: 3.9
"slince/cakephp-permission": "^1.0"

More details here:
https://stackoverflow.com/questions/72271462/cakephp3-entities-relationship-error-when-login-the-error-is-going-after-refres

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.