mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 19:14:45 +02:00

* Remove old admin * Remove controller test * Remove unused exceptions * Remove unused files * More small tweaks * Fix doc block * Remove unused service * Restore these * Add back autoDeploy * Revert "Add back autoDeploy" This reverts commit 630c1e08acf8056ce8e612f376fcd00c23d90aea. * Add these back * Add back exception * Remove ApiController again --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <mail@boy132.de> Co-authored-by: notCharles <charles@pelican.dev>
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Transformers\Api\Application;
|
|
|
|
use App\Models\Role;
|
|
use League\Fractal\Resource\Collection;
|
|
use League\Fractal\Resource\NullResource;
|
|
|
|
class RoleTransformer extends BaseTransformer
|
|
{
|
|
protected array $availableIncludes = [
|
|
'permissions',
|
|
];
|
|
|
|
/**
|
|
* Return the resource name for the JSONAPI output.
|
|
*/
|
|
public function getResourceName(): string
|
|
{
|
|
return Role::RESOURCE_NAME;
|
|
}
|
|
|
|
/**
|
|
* Transform role into a representation for the application API.
|
|
*/
|
|
public function transform(Role $model): array
|
|
{
|
|
return [
|
|
'id' => $model->id,
|
|
'name' => $model->name,
|
|
'created_at' => $model->created_at->toAtomString(),
|
|
'updated_at' => $model->updated_at->toAtomString(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Include the permissions associated with this role.
|
|
*/
|
|
public function includePermissions(Role $model): Collection|NullResource
|
|
{
|
|
$model->loadMissing('permissions');
|
|
|
|
return $this->collection($model->getRelation('permissions'), $this->makeTransformer(RolePermissionTransformer::class), 'permissions');
|
|
}
|
|
}
|