novatoolpermissions icon indicating copy to clipboard operation
novatoolpermissions copied to clipboard

Call to undefined Method: Role::uriKey()

Open StanBarrows opened this issue 6 years ago • 6 comments

Hey there,

I've just installed your package on an empty project to play a little around. Once I created a role I receive this error. The error only appears if I add the relation on the UserRessource. Any ideas?

BelongsToMany::make('Roles', 'roles', Role::class),

image

Set-Up:

  • Laravel Nova: v1.2.1
  • Homestead on OSX 10.14
  • MYSQL DB

Cheers, Stan

StanBarrows avatar Dec 28 '18 14:12 StanBarrows

Hey Stan,

I ran into the same error, solution is to use use Silvanite\NovaToolPermissions\Role; instead of use Silvanite\Brandenburg\Role; in nova/User.php

Your automatic Import probably used the second one instead of the first one, as stated in the readme.

themazim avatar Feb 07 '19 16:02 themazim

The solution is referring to the Nova Role resource instead of you main model:

BelongsToMany::make('Roles', 'roles', \App\Nova\Role::class),

prik avatar Jul 17 '19 12:07 prik

I had no luck with this, since this is what the docs already said to do.

I've got use Silvanite\NovaToolPermissions\Role;

and BelongsToMany::make('Roles', 'roles', Role::class), and I'm still getting this error. I've tried switching to the Brandenberg class, same issue.

The one major thing I can report is that I am using my own App\User class.

paperscissors avatar Jun 11 '20 17:06 paperscissors

Perhaps use php artisan vendor:publish --provider="Silvanite\NovaToolPermissions\Providers\PackageServiceProvider" ? (see docs)

preliot avatar Jun 11 '20 18:06 preliot

I've actually followed these step by step, including the publish with the config, etc. Perhaps I will remove everything and try to install again from scratch.

paperscissors avatar Jun 11 '20 18:06 paperscissors

No idea, I removed everything and went through the install again, the same as before and it worked. Best I can think of is that there was a single character off somewhere throwing the whole thing off, because otherwise everything was identical. Thanks!

paperscissors avatar Jun 11 '20 19:06 paperscissors