bristol-su /
assign-roles
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace BristolSU\Module\AssignRoles\Rules; |
||
| 4 | |||
| 5 | use BristolSU\Support\Authentication\Contracts\Authentication; |
||
| 6 | use Illuminate\Contracts\Validation\Rule; |
||
| 7 | |||
| 8 | class UserIsNotLoggedIntoRole implements Rule |
||
|
0 ignored issues
–
show
|
|||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
|
0 ignored issues
–
show
|
|||
| 12 | * @var Authentication |
||
| 13 | */ |
||
| 14 | private $authentication; |
||
|
0 ignored issues
–
show
|
|||
| 15 | |||
| 16 | 6 | public function __construct(Authentication $authentication) |
|
|
0 ignored issues
–
show
|
|||
| 17 | { |
||
| 18 | 6 | $this->authentication = $authentication; |
|
| 19 | 6 | } |
|
| 20 | |||
| 21 | /** |
||
|
0 ignored issues
–
show
|
|||
| 22 | * @inheritDoc |
||
| 23 | */ |
||
|
0 ignored issues
–
show
|
|||
| 24 | 1 | public function passes($attribute, $value) |
|
| 25 | { |
||
| 26 | 1 | return $this->authentication->getRole() === null || |
|
| 27 | 1 | $this->authentication->getRole()->id() !== (int) $value; |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
|
0 ignored issues
–
show
|
|||
| 31 | * @inheritDoc |
||
| 32 | */ |
||
|
0 ignored issues
–
show
|
|||
| 33 | 1 | public function message() |
|
| 34 | { |
||
| 35 | 1 | return 'You cannot unassign a role you are logged in as'; |
|
| 36 | } |
||
| 37 | } |