# 授权（ACL）和角色

最后，让我们介绍一下Larave的授权系统，它用于确定用户是否有权执行特定的操作。你可以使用如下几个动作来进行检查:can, cannot, allows, 和 denies 。在Laravel 5.2引入了访问控制系统(ACL)。

大多数此授权控制将使用Gate facade执行，但在你的控制器，User模型，中间件和Blade指令中也提供了便利助手。 看看例9-14，了解我们能够做些什么。

{% code title="Example 9-14. Basic usage of the Gate facade" %}

```php
if (Gate::denies('edit-contact', $contact)) { 
    abort(403);
}
if (! Gate::allows('create-contact', Contact::class)) { 
    abort(403);
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/yong-hu-ren-zheng-yu-shou-quan/shou-quan-acl-he-jiao-se-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
