Skip to content

Commit

Permalink
Update AccessResource.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbmaulana authored Nov 20, 2023
1 parent fd0824c commit 8bd1eb3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Http/Resources/AccessResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@ class AccessResource extends JsonResource
public function toArray($request)
{
$accesses = explode(".", $this->resource["name"]);
$resources = explode(",", $accesses[0]);
$actions = explode(",", $accesses[1]);
$targets = explode(",", $accesses[2]);
$resources = @explode(",", $accesses[0]);
$actions = @explode(",", $accesses[1]);
$targets = @explode(",", $accesses[2]);

$ables = [];

foreach ($resources as $resource) {
if (! empty($resources) && ! empty($actions) && ! empty($targets)) {

foreach ($actions as $action) {
foreach ($resources as $resource) {

foreach ($targets as $target) {
foreach ($actions as $action) {

$ables[$resource][$target][$this->resource["id"]][] = $action;
foreach ($targets as $target) {

$ables[$resource][$target][$this->resource["id"]][] = $action;
}
}
}

} else {

$ables[$this->resource["id"]] = $this->resource["name"];
}

return $ables;
Expand Down

0 comments on commit 8bd1eb3

Please sign in to comment.