$this->collection->map(function($data) { return [ 'id' => $data->id, 'name' => $data->getTranslation('name'), 'banner' => uploaded_asset($data->banner), 'icon' => uploaded_asset($data->icon), 'number_of_children' => CategoryUtility::get_immediate_children_count($data->id), 'links' => [ 'products' => route('api.products.category', $data->id), 'sub_categories' => route('subCategories.index', $data->id) ] ]; }) ]; } public function with($request) { return [ 'success' => true, 'status' => 200 ]; } }