Skip to content

Commit

Permalink
Update ACLAdminController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbmaulana authored Oct 26, 2023
1 parent 6041734 commit 0bdebdf
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions stubs/app/Http/Controllers/Admin/ACLAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ class ACLAdminController extends Controller
/**
* @var \Tripteki\ACL\Contracts\Repository\Admin\IACLRoleRepository
*/
protected $ruleRoleAdminRepository;
protected $aclRoleAdminRepository;

/**
* @var \Tripteki\ACL\Contracts\Repository\IACLRepository
*/
protected $ruleUserAdminRepository;
protected $aclUserAdminRepository;

/**
* @param \Tripteki\ACL\Contracts\Repository\Admin\IACLRoleRepository $ruleRoleAdminRepository
* @param \Tripteki\ACL\Contracts\Repository\IACLRepository $ruleUserAdminRepository
* @param \Tripteki\ACL\Contracts\Repository\Admin\IACLRoleRepository $aclRoleAdminRepository
* @param \Tripteki\ACL\Contracts\Repository\IACLRepository $aclUserAdminRepository
* @return void
*/
public function __construct(IACLRuleRoleRepository $ruleRoleAdminRepository, IACLRuleUserRepository $ruleUserAdminRepository)
public function __construct(IACLRuleRoleRepository $aclRoleAdminRepository, IACLRuleUserRepository $aclUserAdminRepository)
{
$this->ruleRoleAdminRepository = $ruleRoleAdminRepository;
$this->ruleUserAdminRepository = $ruleUserAdminRepository;
$this->aclRoleAdminRepository = $aclRoleAdminRepository;
$this->aclUserAdminRepository = $aclUserAdminRepository;
}

/**
Expand Down Expand Up @@ -92,33 +92,33 @@ public function rule(ACLValidation $request, $context, $object)

if ($context == ACLValidation::GRANT_PERMISSIONS_TO_ROLE || $context == ACLValidation::REVOKE_PERMISSIONS_FROM_ROLE) {

$this->ruleRoleAdminRepository->forRole($object);
$this->aclRoleAdminRepository->forRole($object);

foreach ($form["rules"] as $rule) {

if ($context == ACLValidation::GRANT_PERMISSIONS_TO_ROLE) {

$data[] = $this->ruleRoleAdminRepository->grant($rule);
$data[] = $this->aclRoleAdminRepository->grant($rule);

} else if ($context == ACLValidation::REVOKE_PERMISSIONS_FROM_ROLE) {

$data[] = $this->ruleRoleAdminRepository->revoke($rule);
$data[] = $this->aclRoleAdminRepository->revoke($rule);
}
}

} else if ($context == ACLValidation::GRANT_ROLES_TO_USER || $context == ACLValidation::REVOKE_ROLES_FROM_USER) {

$this->ruleUserAdminRepository->setUser(app(AuthModelContract::class)->findOrFail($object));
$this->aclUserAdminRepository->setUser(app(AuthModelContract::class)->findOrFail($object));

foreach ($form["rules"] as $rule) {

if ($context == ACLValidation::GRANT_ROLES_TO_USER) {

$data[] = $this->ruleUserAdminRepository->grantAs($rule);
$data[] = $this->aclUserAdminRepository->grantAs($rule);

} else if ($context == ACLValidation::REVOKE_ROLES_FROM_USER) {

$data[] = $this->ruleUserAdminRepository->revokeAs($rule);
$data[] = $this->aclUserAdminRepository->revokeAs($rule);
}
}
}
Expand Down

0 comments on commit 0bdebdf

Please sign in to comment.