> For the complete documentation index, see [llms.txt](https://liseen315.gitbook.io/laravel/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liseen315.gitbook.io/laravel/yong-hu-ren-zheng-yu-shou-quan/shou-quan-acl-he-jiao-se-1/jian-cha-yong-hu-shi-li.md).

# 检查用户实例

如果不在控制器内,你更有可能检查特定用户的功能而不是当前经过身份验证的用户。 可以使用Gate facade的forUser()方法，但有时语法可能会略微差别。

值得庆幸的是,User 类上的Authorizable提供了三个可读性好的方法:$user->can(), $user->cant(), 和 $user->cannot()，你可能猜到了，cant() 和 cannot() 做同样的事，can()与他们相反。

查看示例9-22

{% code title="Example 9-22. Checking authorization on a User instance" %}

```php
$user = User::find(1);
if ($user->can('create-contact')) { 
    // Do something
}
```

{% endcode %}

背后这些方法将参数传给Gate,如之前的实例:`Gate::forUser($user)->check('create-contact')`
