1 | <?php namespace Modules\User\Entities\Sentry; |
||
12 | class User extends SentryModel implements UserInterface |
||
13 | { |
||
14 | use PresentableTrait; |
||
15 | |||
16 | protected $fillable = [ |
||
17 | 'email', |
||
18 | 'password', |
||
19 | 'permissions', |
||
20 | 'first_name', |
||
21 | 'last_name', |
||
22 | 'activated', |
||
23 | ]; |
||
24 | |||
25 | protected $presenter = 'Modules\User\Presenters\UserPresenter'; |
||
26 | |||
27 | public function groups() |
||
28 | { |
||
29 | return $this->belongsToMany(static::$groupModel, static::$userGroupsPivot, 'user_id'); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Checks if a user belongs to the given Role ID |
||
34 | * @param int $roleId |
||
35 | * @return bool |
||
36 | */ |
||
37 | public function hasRoleId($roleId) |
||
38 | { |
||
39 | $role = Sentry::findGroupById($roleId); |
||
40 | |||
41 | return $this->inGroup($role); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Checks if a user belongs to the given Role Name |
||
46 | * @param string $name |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function hasRoleName($name) |
||
50 | { |
||
51 | $role = Sentry::findGroupByName($name); |
||
52 | |||
53 | return $this->inGroup($role); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Check if the current user is activated |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function isActivated() |
||
64 | |||
65 | public function __call($method, $parameters) |
||
82 | } |
||
83 |