1<?php
2
3namespace Illuminate\Foundation\Auth\Access;
4
5use Illuminate\Contracts\Auth\Access\Gate;
6
7trait Authorizable
8{
9    /**
10     * Determine if the entity has the given abilities.
11     *
12     * @param  iterable|string  $abilities
13     * @param  array|mixed  $arguments
14     * @return bool
15     */
16    public function can($abilities, $arguments = [])
17    {
18        return app(Gate::class)->forUser($this)->check($abilities, $arguments);
19    }
20
21    /**
22     * Determine if the entity has any of the given abilities.
23     *
24     * @param  iterable|string  $abilities
25     * @param  array|mixed  $arguments
26     * @return bool
27     */
28    public function canAny($abilities, $arguments = [])
29    {
30        return app(Gate::class)->forUser($this)->any($abilities, $arguments);
31    }
32
33    /**
34     * Determine if the entity does not have the given abilities.
35     *
36     * @param  iterable|string  $abilities
37     * @param  array|mixed  $arguments
38     * @return bool
39     */
40    public function cant($abilities, $arguments = [])
41    {
42        return ! $this->can($abilities, $arguments);
43    }
44
45    /**
46     * Determine if the entity does not have the given abilities.
47     *
48     * @param  iterable|string  $abilities
49     * @param  array|mixed  $arguments
50     * @return bool
51     */
52    public function cannot($abilities, $arguments = [])
53    {
54        return $this->cant($abilities, $arguments);
55    }
56}
57