Register the abilities.

@param array $abilities_permissions

@return bool
496636
public function registerPermissions(array $abilities_permissions)
    {
        try {

            // a callback that is run before all other authorization checks
            if (isset($abilities_permissions['before'])) {
                if (is_array($abilities_permissions['before'])) {
                    $this->runGateBefore($abilities_permissions['before']);
                } else {
                    Log::alert('abilities "before" must be an array, no before policies registered!');
                }
            }

            // Register abilities and their polices
            if (isset($abilities_permissions['abilities'])) {
                if (is_array($abilities_permissions['abilities'])) {
                    $this->runGateDefine($abilities_permissions['abilities']);
                } else {
                    Log::alert('abilities must be an array, no abilities registered!');
                }
            }

            //  you may not modify the result of the authorization check from an after callback
            if (isset($abilities_permissions['after'])) {
                if (is_array($abilities_permissions['after'])) {
                    $this->runGateAfter($abilities_permissions['after']);
                } else {
                    Log::alert('abilities "after" must be an array, no "after" callbacks registered!');
                }
            }

            return true;
        } catch (Exception $e) {
            Log::alert('Could not register abilities .. '.$e);

            return false;
        }
    }
648271
public function authorize($ability, $arguments = array())
    {
        list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);

        $gate = App::make('Nova\Auth\Access\GateInterface');

        return $this->authorizeAtGate($gate, $ability, $arguments);
    }
1326130
public function can($ability, $model, $user = false)
    {
        if ($user === false) {
            $user = auth()->user();
        }

        $this->authorized = $user->can($ability, $model, $user);

        return $this;
    }
1185455
protected static function hasTypeAccessOwner(array $capabilities, array $user, array $url): bool
    {
        $entity = static::getEntityFromUrl($url);

        foreach ($capabilities as $capability) {
            if (!static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                continue;
            }

            // if url does not include an id and user has owner capability
            // access, to current module action, allow him access. (index action)
            if (empty($entity)) {
                return true;
            }

            // if url includes an id, check capability's field value from the entity
            // against current user id and if they match allow him access. (view, edit actions etc)
            $field = $capability->getField();

            if ($entity->get($field) === $user['id']) {
                return true;
            }
        }

        return false;
    }
1181214
public function allow($ability = null, $model = null)
    {
        if (is_null($ability)) {
            return new GivesAbilities($this);
        }

        (new GivesAbilities($this))->to($ability, $model);

        return $this;
    }
32589
public function allows($ability, $arguments = [])
    {
        if (!is_array($arguments)) {
            $arguments = [ $arguments ];
        }

        array_unshift($arguments, $ability);
        return call_user_func_array([ $this->gatekeeper, 'allows'], $arguments);
    }
909799
public function check($abilities, $arguments = [])
    {
        return collect($abilities)->every(function ($ability) use ($arguments) {
            try {
                return (bool) $this->raw($ability, $arguments);
            } catch (AuthorizationException $e) {
                return false;
            }
        });
    }
387568
public function hasAccess($permissions)
    {
        if ($this->permissions->isEmpty())
        {
            $this->mergePermissions($this->userPermissions, $this->rolePermissions);
        }

        if (func_num_args() > 1)
        {
            $permissions = func_get_args();
        }

        foreach ((array) $permissions as $permissionName)
        {
            if (! $this->allows($permissionName))
            {
                return false;
            }
        }

        return true;
    }
409682
protected function syncAbilities($abilities, $options = ['forbidden' => false])
    {
        $abilityKeys = $this->getAbilityIds($abilities);
        $authority = $this->getAuthority();
        $relation = $authority->abilities();

        $this->newPivotQuery($relation)
             ->where('entity_type', $authority->getMorphClass())
             ->whereNotIn($this->getRelatedPivotKeyName($relation), $abilityKeys)
             ->where('forbidden', $options['forbidden'])
             ->delete();

        if ($options['forbidden']) {
            (new ForbidsAbilities($this->authority))->to($abilityKeys);
        } else {
            (new GivesAbilities($this->authority))->to($abilityKeys);
        }
    }
697051
protected function validate_authority( $capability ) {
		if ( ! $this->app->user_can( $capability ) ) {
			return new \WP_Error( 400, $this->app->translate( 'You have no authority.' ) );
		}

		return true;
	}
921199
protected function createMissingAbilities($existing, array $abilities, $attributes = [])
    {
        $missing = array_diff($abilities, $existing->pluck('name')->all());

        return array_map(function ($ability) use ($attributes) {
            return Models::ability()->create($attributes + ['name' => $ability]);
        }, $missing);
    }
461249
public function ability($roles, $permissions, $options = [])
    {
        if ($user = $this->user()) {
            return $user->ability($roles, $permissions, $options);
        }

        return false;
    }
965636
public function add_abilities($new_abbilities)
    {
        foreach ($new_abbilities as $abbility_str) {
            $camel = '';
            $abbility_str = str_replace(':', '', $abbility_str);
            foreach (explode('_', $abbility_str) as $str) {
                $camel .= ucfirst($str);
            }
            $class_name = 'PHPWarrior\Abilities\\' . $camel;
            $this->abilities[$abbility_str] = new $class_name($this);
        }
        return $this;
    }
256196
public function can($ability, $arguments = [])
    {
        foreach ($this->abilities as $check) {
            if (fnmatch($check, $ability)) {
                return true;
            }
        }

        return false;
    }
725242
public function can($ability, $arguments = [])
    {
        return app(Gate::class)->forUser($this)->check($ability, $arguments);
    }
1319985
public function allow($roles, $actions, $allow = true, $descriptions = null, $categories = null)
    {
        $this->setAuthorization($roles, $actions, $allow);

        return $this->save($descriptions, $categories);
    }
752087
public function registerGatePolicies(): void
    {
        if (!\Schema::hasTable('permissions')) {
            return;
        }

        $permissions = Permission::all(['handle', 'type']);

        foreach ($permissions as $permission) {
            Gate::define($permission->code, function (Authenticatable $user, ?Model $model = null, string $userForeignKey = 'user_id') use ($permission) {
                return $user->hasPermission($permission->code, $model, $userForeignKey);
            });
        }
    }