Silvanite / novatoolpermissions

Laravel Nova Permissions Tool (User, Roles and Permissions / Access Control (ACL))
MIT License
101 stars 33 forks source link

Gate Registered But Access Won't Work #67

Open zidaneiqbal opened 3 years ago

zidaneiqbal commented 3 years ago

image As You Can See In Image Rapor Still Show When I Dont Give Permission.

Here My > AuthServiceProvider.php

` protected $policies = [ ButtonRapor::class => RaporPolicy::class, ];

/**
 * Register any authentication / authorization services.
 *
 * @return void
 */
public function boot()
{
    collect([
        'viewRapor',
        'manageRapor',
    ])->each(function ($permission) {
        Gate::define($permission, function ($user) use ($permission) {
            if ($this->nobodyHasAccess($permission)) {
                return true;
            }

            return $user->hasRoleWithPermission($permission);
        });
    });

    $this->registerPolicies();

    //
}`

And Here My Policy. `class RaporPolicy { use HandlesAuthorization;

public function __construct()
{
    //
}
public function viewAny($user)
{
    return Gate::any(['viewRapor', 'manageRapor'], $user);
}

public function view($user, $post)
{
    return Gate::any(['viewRapor', 'manageRapor'], $user, $post);
}

public function create($user)
{
    return false;
}

public function update($user, $post)
{
    return false;
}

public function delete($user, $post)
{
    return false;
}

public function restore($user, $post)
{
    return false;
}

public function forceDelete($user, $post)
{
    return false;
}

} `