Created
May 13, 2018 11:06
-
-
Save yasaryousuf/eff290fcfeee61a73012dba5785f3df2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function hasAnyRole($roles) | |
{ | |
return null !== $this->roles()->whereIn('name', $roles)->first(); | |
} | |
public function hasRole($role) | |
{ | |
return null !== $this->roles()->where('name', $role)->first(); | |
} | |
public function isSubscriber() | |
{ | |
foreach ($this->roles()->get() as $role) | |
{ | |
if ($role->name == 'Subscriber') | |
{ | |
return true; | |
} | |
} | |
} | |
public function is($roleName) | |
{ | |
foreach ($this->roles()->get() as $role) | |
{ | |
if ($role->name == $roleName) | |
{ | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment