From 3af9a5dff9c468a76bd3a1271232242afce9d41d Mon Sep 17 00:00:00 2001 From: hsbmaulana Date: Mon, 14 Oct 2024 15:50:06 +0700 Subject: [PATCH] fix(core): initial --- composer.json | 2 +- src/Helpers/Accesses.php | 3 +- src/Http/Resources/AccessResource.php | 44 ------------------- .../Http/Controllers/ACL/ACLController.php | 2 +- 4 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 src/Http/Resources/AccessResource.php diff --git a/composer.json b/composer.json index 95dbdcb..8545b42 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tripteki/laravelphp-acl", - "version": "2.0.2", + "version": "2.0.3", "description": "Trip Teknologi's Laravel.php ACLs", "readme": "README.md", diff --git a/src/Helpers/Accesses.php b/src/Helpers/Accesses.php index c871beb..509bb9c 100644 --- a/src/Helpers/Accesses.php +++ b/src/Helpers/Accesses.php @@ -3,7 +3,6 @@ use Tripteki\Helpers\Contracts\AuthModelContract; use Tripteki\ACL\Contracts\Repository\IACLRepository; use Tripteki\ACL\Traits\RolePermissionTrait; -use Tripteki\ACL\Http\Resources\AccessResource; use Illuminate\Support\Facades\Auth; if (! function_exists("accesses")) @@ -38,6 +37,6 @@ function accesses(\Illuminate\Database\Eloquent\Model|null $user = null, $withOw else $accesses = $repository->permissions()->toArray(); } - return AccessResource::collection($accesses)->resolve(); + return $accesses; }; } diff --git a/src/Http/Resources/AccessResource.php b/src/Http/Resources/AccessResource.php deleted file mode 100644 index 074dfe5..0000000 --- a/src/Http/Resources/AccessResource.php +++ /dev/null @@ -1,44 +0,0 @@ -resource["name"]); - $resources = @explode(",", $accesses[0]); - $actions = @explode(",", $accesses[1]); - $targets = @explode(",", $accesses[2]); - - $ables = []; - - if (! empty($resources) && ! empty($actions) && ! empty($targets)) { - - foreach ($resources as $resource) { - - foreach ($actions as $action) { - - foreach ($targets as $target) { - - $ables[$resource][$target][$this->resource["id"]][] = $action; - } - } - } - - } else { - - $ables[$this->resource["id"]] = $this->resource["name"]; - } - - return $ables; - } -}; diff --git a/stubs/app/Http/Controllers/ACL/ACLController.php b/stubs/app/Http/Controllers/ACL/ACLController.php index 140e3a0..777dc38 100644 --- a/stubs/app/Http/Controllers/ACL/ACLController.php +++ b/stubs/app/Http/Controllers/ACL/ACLController.php @@ -29,7 +29,7 @@ public function index(Request $request) $data = []; $statecode = 200; - $data = accesses($request->user()); + $data = accesses($request->user(), false); return iresponse($data, $statecode); }