public function giveRolePermission(int $role_id, string $permission_name, bool $inverse)
    {

        $role = $this->getRole($role_id);

        $permission = PermissionModel::firstOrNew([
            'title' => $permission_name,
        ]);

        // If the role does not already have the permission
        // add it. We will also apply the inverse rule as an
        // extra attribute on save()
        if (! $role->permissions->contains($permission->id))
            $role->permissions()->save($permission, ['not' => $inverse]);

    }
public function giveRolePermission(int $role_id, string $permission_name, bool $inverse)
    {

        $role = $this->getRole($role_id);

        $permission = PermissionModel::firstOrNew([
            'title' => $permission_name,
        ]);

        // If the role does not already have the permission
        // add it. We will also apply the inverse rule as an
        // extra attribute on save()
        if (! $role->permissions->contains($permission->id))
            $role->permissions()->save($permission, ['not' => $inverse]);

    }
public function giveRolePermission ( int $ role_id , string $ permission_name , bool $ inverse ) { $ role = $ this -> getRole ( $ role_id ) ; $ permission = PermissionModel :: firstOrNew ( [ 'title' => $ permission_name , ] ) ; // If the role does not already have the permission // add it. We will also apply the inverse rule as an // extra attribute on save() if ( ! $ role -> permissions -> contains ( $ permission -> id ) ) $ role -> permissions ( ) -> save ( $ permission , [ 'not' => $ inverse ] ) ; }
Give a Role a permission.

@param int    $role_id
@param string $permission_name
@param bool   $inverse
Give a Role a permission .