mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
26 lines
551 B
PHP
26 lines
551 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Transformers;
|
|
|
|
use App\Models\RootCategory;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class CategoryTransformer extends TransformerAbstract
|
|
{
|
|
/**
|
|
* Transform a root category into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function transform(RootCategory $category): array
|
|
{
|
|
return [
|
|
'id' => $category->id,
|
|
'name' => $category->title,
|
|
'subcategories' => $category->categories()->pluck('title', 'id'),
|
|
];
|
|
}
|
|
}
|