Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
Http
/
Resources
/
User
:
CategoryTreeResource.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Http\Resources\User; use Illuminate\Http\Resources\Json\JsonResource; class CategoryTreeResource extends JsonResource { public function toArray($request) { $child_categories = []; foreach ($this->categoryTree as $tree){ $child_categories[] = [ 'id' => $tree->id, 'name' => $tree->name, 'featured_image' => $tree->featured_image ? [ 'url' => $tree->featured_image->url, 'thumbnail' => $tree->featured_image->thumbnail, 'preview' => $tree->featured_image->preview, ] : null, ]; } return [ 'id' => $this->id, 'name' => $this->name, 'featured_image' => $this->featured_image ? [ 'url' => $this->featured_image->url, 'thumbnail' => $this->featured_image->thumbnail, 'preview' => $this->featured_image->preview, ] : null, 'child_categories' => $child_categories, ]; } }