adrema/app/Group/Resources/GroupResource.php

46 lines
878 B
PHP

<?php
namespace App\Group\Resources;
use App\Group;
use App\Lib\HasMeta;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Group
*/
class GroupResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array<string, mixed>
*/
public function toArray($request)
{
return [
'name' => $this->name,
'inner_name' => $this->inner_name,
'parent_id' => $this->parent_id,
'id' => $this->id,
'level' => $this->level?->value,
];
}
/**
* @return array<string, mixed>
*/
public static function meta(): array
{
return [
'links' => [
'bulkstore' => route('group.bulkstore'),
]
];
}
}