2023-12-30 02:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Group\Resources;
|
|
|
|
|
2023-12-30 19:02:15 +01:00
|
|
|
use App\Group;
|
2023-12-30 02:02:07 +01:00
|
|
|
use App\Lib\HasMeta;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
2023-12-30 19:02:15 +01:00
|
|
|
/**
|
|
|
|
* @mixin Group
|
|
|
|
*/
|
2023-12-30 02:02:07 +01:00
|
|
|
class GroupResource extends JsonResource
|
|
|
|
{
|
|
|
|
|
|
|
|
use HasMeta;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
2023-12-30 19:02:15 +01:00
|
|
|
* @return array<string, mixed>
|
2023-12-30 02:02:07 +01:00
|
|
|
*/
|
|
|
|
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,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-12-30 19:02:15 +01:00
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
2023-12-30 02:02:07 +01:00
|
|
|
public static function meta(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'links' => [
|
|
|
|
'bulkstore' => route('group.bulkstore'),
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|