@@ 14-38 (lines=25) @@ | ||
11 | * |
|
12 | * @author Mahmoud Zalt <[email protected]> |
|
13 | */ |
|
14 | class FindPermissionTask extends Task |
|
15 | { |
|
16 | ||
17 | protected $repository; |
|
18 | ||
19 | public function __construct(PermissionRepository $repository) |
|
20 | { |
|
21 | $this->repository = $repository; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param $permissionNameOrId |
|
26 | * |
|
27 | * @return Permission |
|
28 | */ |
|
29 | public function run($permissionNameOrId): Permission |
|
30 | { |
|
31 | $query = is_numeric($permissionNameOrId) ? ['id' => $permissionNameOrId] : ['name' => $permissionNameOrId]; |
|
32 | ||
33 | $permission = $this->repository->findWhere($query)->first(); |
|
34 | ||
35 | return $permission; |
|
36 | } |
|
37 | ||
38 | } |
|
39 |
@@ 14-38 (lines=25) @@ | ||
11 | * |
|
12 | * @author Mahmoud Zalt <[email protected]> |
|
13 | */ |
|
14 | class FindRoleTask extends Task |
|
15 | { |
|
16 | ||
17 | protected $repository; |
|
18 | ||
19 | public function __construct(RoleRepository $repository) |
|
20 | { |
|
21 | $this->repository = $repository; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param $roleNameOrId |
|
26 | * |
|
27 | * @return \App\Containers\Authorization\Models\Role |
|
28 | */ |
|
29 | public function run($roleNameOrId): Role |
|
30 | { |
|
31 | $query = is_numeric($roleNameOrId) ? ['id' => $roleNameOrId] : ['name' => $roleNameOrId]; |
|
32 | ||
33 | $role = $this->repository->findWhere($query)->first(); |
|
34 | ||
35 | return $role; |
|
36 | } |
|
37 | ||
38 | } |
|
39 |