33 lines
956 B
PHP
33 lines
956 B
PHP
<?php
|
|
|
|
namespace Modules\Cms\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
|
|
class CategoryCollection extends ResourceCollection
|
|
{
|
|
|
|
/**
|
|
* Notes :
|
|
* @Date : 2021/4/25 1:32 下午
|
|
* @Author : < Jason.C >
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
return $this->collection->map(function ($category) {
|
|
return [
|
|
'category_id' => $category->id,
|
|
'title' => $category->title,
|
|
'slug' => $category->slug,
|
|
'description' => $category->description,
|
|
'cover' => $category->cover_url,
|
|
'pictures' => $category->pictures_url,
|
|
'created_at' => (string) $category->created_at,
|
|
'children' => new self($category->children),
|
|
];
|
|
})->toArray();
|
|
}
|
|
|
|
} |