Skip to content

Deny a permission for a user #2160

Discussion options

You must be logged in to vote

Well i got time to implement the trait @erikn69 made
But i used to do minor modifications the trait.
Create HasRolesAndForbiddenPermissions.php file in App/Traits/Permissions folder with the content below:

<?php

namespace App\Traits\Permissions;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Collection;
use Spatie\Permission\Contracts\Permission;
use Spatie\Permission\Exceptions\PermissionDoesNotExist;
use Spatie\Permission\PermissionRegistrar;

trait HasRolesAndForbiddenPermissions
{
    use \Spatie\Permission\Traits\HasRoles {
        hasPermissionTo as protected hasPermissionToTrait;
        hasPermissionViaRol…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@Allgoodnamesargone
Comment options

@erikn69
Comment options

@Allgoodnamesargone
Comment options

@erikn69
Comment options

@Allgoodnamesargone
Comment options

Answer selected by Allgoodnamesargone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants