32 lines
989 B
PHP
32 lines
989 B
PHP
<?php
|
|
|
|
/**
|
|
* @author Ball Studios <https://git.balls.studio>
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace Pterodactyl\Addons\AdvancedAdmin\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class RoleResource extends JsonResource
|
|
{
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'description' => $this->description,
|
|
'color' => $this->color,
|
|
'priority' => $this->priority,
|
|
'is_default' => $this->is_default,
|
|
'in_use' => $this->whenLoaded('assignments', fn () => $this->assignments->count() > 0),
|
|
'permissions' => $this->whenLoaded('permissions', function () {
|
|
return $this->permissions->pluck('value', 'permission');
|
|
}),
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|