Git Product home page Git Product logo

kiritokatklian / nova-permission Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vyuldashev/nova-permission

68.0 68.0 15.0 1.17 MB

A Laravel Nova tool for Spatie's laravel-permission library

Home Page: https://novapackages.com/packages/vyuldashev/nova-permission

License: MIT License

PHP 100.00%
laravel-nova laravel-nova-3 laravel-nova-4 nova permissions spatie-laravel spatie-laravel-permission

nova-permission's People

Contributors

amanpatel avatar ashgibson avatar charlielangridge avatar dividy avatar drbyte avatar erhansogut avatar f-liva avatar fkeloks avatar gnanakeethan avatar igedeon avatar johnpaulmedina avatar kiritokatklian avatar kussie avatar letrams avatar lucascolette avatar marcorivm avatar melvintehu avatar mxm1070 avatar nalingia avatar pabloguerrez avatar potsky avatar reflow1319 avatar rvxlab avatar sadeghpm avatar shalawani avatar siebeve avatar simonbarrettact avatar stepanenko3 avatar suleymanozev avatar vyuldashev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nova-permission's Issues

Conflict with Policy.

When this package is installed the Policy does not work. What should I do to make working both - this package and Policy?

Call to undefined method App\Models\User:roles() and App\Models\User:permissions()

After installation i got this errors while showing the user details ...

Call to undefined method App\Models\User:roles() and Call to undefined method App\Models\User:permissions()

I checked installation instructions but i don't find any mistakes.

In the log the following errors occurred:

[2022-04-14 08:03:40] local.ERROR: Call to undefined method App\Models\User::permissions() {"userId":1,"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method App\Models\User::permissions() at /var/www/html/nova/nova-test/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:71)
[stacktrace]

Do you have any idea?

Extremely slow when viewing roles.

return Auth::user()->can('view', $permission);

We have about 200 permissions in our system and about 19 roles, and this line of code is causing extremely slow responses when trying to load the roles list page. So when viewing the roles page, it has to fetch about 4000 Permission models, and while the database is pretty fast, the laravel model hydration is causing delays in app code.

In our system, only super-admins can view/manage permissions, so I am questioning why this code is needed. Can we remove this, or somehow make it optional during the field setup?

I can submit a PR if this works.

Inertia issue after package installation

Hello,

After the installation of the package the following error occurs when clicking on a button or link in Nova (so it isn't possible to do anything) : "All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.".

We are using the newest version of nova and of the package, php 8.2 and spatie/laravel-permission ^5.8. No other nova packages are installed.

Any idea how we could resolve this?

Thank you in advance!

Menu issue after installing this package

After installing this package, all menus can't be clicked and this error occurred
(in promise) TypeError: Cannot read properties of undefined (reading 'toString')
image

Laraval Nova 4 support

Class Vyuldashev\\NovaPermission\\NovaPermissionTool contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Laravel\\Nova\\Tool::menu)

Bug with RoleBooleanGroup::make('Roles') in User.php resource

Hello.
I have an error in Nova Users resource when I'm adding this code RoleBooleanGroup::make('Roles'), to app\Nova\User.php
Thank you for help.

local.ERROR: Vyuldashev\NovaPermission\RoleBooleanGroup::Vyuldashev\NovaPermission\{closure}(): Argument #1 ($permissions) must be of type Illuminate\Support\Collection, null given {"userId":1,"exception":"[object] (TypeError(code: 0): Vyuldashev\\NovaPermission\\RoleBooleanGroup::Vyuldashev\\NovaPermission\\{closure}(): Argument #1 ($permissions) must be of type Illuminate\\Support\\Collection, null given at /...../vendor/kiritokatklian/nova-permission/src/RoleBooleanGroup.php:20)
[stacktrace]
#0 [internal function]: Vyuldashev\\NovaPermission\\RoleBooleanGroup::Vyuldashev\\NovaPermission\\{closure}(NULL, Object(App\\Models\\User), 'roles')

Redeclaring `menu` method

Inside of NovaPermissionTool.php, the menu(Request $request) method is declared twice, which causes an error in environments with low error tolerance.

SQL error in user index

I'm on laravel 9.2 and my user index throws the SQL error below

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'model_has_roles.' in 'where clause' (SQL: select `roles`.*, `model_has_roles`.`model_id` as `pivot_model_id`, `model_has_roles`.`role_id` as `pivot_role_id`, `model_has_roles`.`model_type` as `pivot_model_type` from `roles` inner join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` where `model_has_roles`.`model_id` = 1 and `model_has_roles`.`model_type` = App\Models\User and `model_has_roles`.`` is null and (`roles`.`` is null or `roles`.`` is null))

Anyone facing the same problem?

Hide role permission

Is there a way to hide Role and Permission from nova menu
I want the admin user to be able to select a role when creating users but i don't want him to be able to add role or permision
so no need for the menus
How can i achive this ?

getModelForGuard(): Argument #1 ($guard) must be of type string, null given

I am getting an exception when viewing both the Role and Permission resource:

getModelForGuard(): Argument #1 ($guard) must be of type string, null given, called in /Users/fredrik/Documents/code/xxx/vendor/vyuldashev/nova-permission/src/Role.php on line 92

It's referencing this line:
https://github.com/kiritokatklian/nova-permission/blob/master/src/Role.php#L99-L101

Specifically is the $this->guard_name null for some reason. When I look in the DB it's set to web and when I hardcode the $userResource = \App\Nova\User::class instead it doesn't throw an exception but it doesn't show the User. Very strange.

[bug] [V3] Not working in Multi-tenant environment

I have a Multi-tenant environment based upon https://tenancyforlaravel.com/saas-boilerplate/ and https://github.com/archtechx/tenancy

In order to make sure that it is clear that tables live in the Central or Tenant "domain" I have to prefix all Central-related tables.
This causes the Validator to guess the wrong connection, because of the prefix.
In order to combat this, we can either pass the class name to the Validator, so the getConnectionName function is called on the model, which does return the right connection name.

Permissions.php

            Text::make(__('nova-permission-tool::permissions.name'), 'name')
                ->rules(['required', 'string', 'max:255'])
                ->creationRules('unique:'.config('permission.models.permission'))
                ->updateRules('unique:'.config('permission.models.permission').',name,{{resourceId}}'),

and Roles,php

            Text::make(__('nova-permission-tool::roles.name'), 'name')
                ->rules(['required', 'string', 'max:255'])
                ->creationRules('unique:'.config('permission.models.role'))
                ->updateRules('unique:'.config('permission.models.role').',name,{{resourceId}}'),

This fixes the problem (at least for me) ๐Ÿ˜„

PHP 8.1.5
Laravel Framework 9.10.1
Laravel Nova v3.32.0
kiritokatklian/nova-permission v3.2.2

Undefined array key "guard_name"

When viewing a Role or Permission I get this exception:

Undefined array key "guard_name" {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined array key "guard_name" at /Users/fredrik/Documents/code/xxx/vendor/spatie/laravel-permission/src/Models/Role.php:73)

The error is coming from the "model"-relation and I can see that the Roles guard_name is set: print screen

Also, the $attributes is empty when dumping info("model", [$this->attributes]); it the users()-function on the Role model.

No data permissions

Hey! I am currently using this package to represent any permissions attached to a user.

On localhost, the permissions are visible and editable.

image

When I am deploying my localhost to a dev environment, the PermissionBooleanGroup gives me a "No Data".

image

Do you have any idea what is going wrong here?

Set the Resource Model according to Spatie config

Hi
I am using custom Permission and Role models (i replaced them in the Spatie config). The reason i am using custom model isin order to Audit change with the laravel auditing package.
It seems that the package have the Spatie model hard coded.
Maybe in the Resource constructor we should get the model from the spatie config ?
Thanks for your help here

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.