public function detailsJSON($lang, $id)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Categories', 'update')) {
            return $this->noPermission();
        }

        $category = Category::find($id);
        $featuredImage = Media::find($category->featuredImageID);
        if($category) {
            $media = [];
            if ($featuredImage) {
                $media['feature_image'] = [$featuredImage];
            }

            // get parent title and id translated
            if($category->parent) {
                $parentCategoryID = $category->parent->categoryID;
                $parentTitle = $category->parent->title;
                // get parent
                $category->parentCategory = [
                    'categoryID' => $parentCategoryID,
                    'title' => $parentTitle,
                ];
            }

            // handle custom fields
            $customFieldGroups = CustomFieldGroup::findGroups('category', 'create', $id, 'none');
            $customFieldOBJ = new CustomField();
            if($category->customFields) {
                $customFieldOBJ->constructValues($customFieldGroups, $category->customFields);
                $media = array_merge($media, $customFieldOBJ->getMedia());
            }

            $final = array(
                'details' => $category,
                'languages' => Language::all(),
                'media' => $media,
                'customFieldsValues' => $customFieldOBJ->getCustomFieldValues(),
                'customFieldsGroups' => $customFieldGroups,
            );

            // Fire event
            $final['events'] = Event::fire('category:pre_update', [$final]);
        }else{
            $final = array(
                'error' => 'Category not found'
            );
        }
        return $final;
    }
public function detailsJSON($lang, $id)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Categories', 'update')) {
            return $this->noPermission();
        }

        $category = Category::find($id);
        $featuredImage = Media::find($category->featuredImageID);
        if($category) {
            $media = [];
            if ($featuredImage) {
                $media['feature_image'] = [$featuredImage];
            }

            // get parent title and id translated
            if($category->parent) {
                $parentCategoryID = $category->parent->categoryID;
                $parentTitle = $category->parent->title;
                // get parent
                $category->parentCategory = [
                    'categoryID' => $parentCategoryID,
                    'title' => $parentTitle,
                ];
            }

            // handle custom fields
            $customFieldGroups = CustomFieldGroup::findGroups('category', 'create', $id, 'none');
            $customFieldOBJ = new CustomField();
            if($category->customFields) {
                $customFieldOBJ->constructValues($customFieldGroups, $category->customFields);
                $media = array_merge($media, $customFieldOBJ->getMedia());
            }

            $final = array(
                'details' => $category,
                'languages' => Language::all(),
                'media' => $media,
                'customFieldsValues' => $customFieldOBJ->getCustomFieldValues(),
                'customFieldsGroups' => $customFieldGroups,
            );

            // Fire event
            $final['events'] = Event::fire('category:pre_update', [$final]);
        }else{
            $final = array(
                'error' => 'Category not found'
            );
        }
        return $final;
    }
public function detailsJSON ( $ lang , $ id ) { // check if user has permissions to access this link if ( ! User :: hasAccess ( 'Categories' , 'update' ) ) { return $ this -> noPermission ( ) ; } $ category = Category :: find ( $ id ) ; $ featuredImage = Media :: find ( $ category -> featuredImageID ) ; if ( $ category ) { $ media = [ ] ; if ( $ featuredImage ) { $ media [ 'feature_image' ] = [ $ featuredImage ] ; } // get parent title and id translated if ( $ category -> parent ) { $ parentCategoryID = $ category -> parent -> categoryID ; $ parentTitle = $ category -> parent -> title ; // get parent $ category -> parentCategory = [ 'categoryID' => $ parentCategoryID , 'title' => $ parentTitle , ] ; } // handle custom fields $ customFieldGroups = CustomFieldGroup :: findGroups ( 'category' , 'create' , $ id , 'none' ) ; $ customFieldOBJ = new CustomField ( ) ; if ( $ category -> customFields ) { $ customFieldOBJ -> constructValues ( $ customFieldGroups , $ category -> customFields ) ; $ media = array_merge ( $ media , $ customFieldOBJ -> getMedia ( ) ) ; } $ final = array ( 'details' => $ category , 'languages' => Language :: all ( ) , 'media' => $ media , 'customFieldsValues' => $ customFieldOBJ -> getCustomFieldValues ( ) , 'customFieldsGroups' => $ customFieldGroups , ) ; // Fire event $ final [ 'events' ] = Event :: fire ( 'category:pre_update' , [ $ final ] ) ; } else { $ final = array ( 'error' => 'Category not found' ) ; } return $ final ; }
JSON object with details for a specific category.
All data used in update form.

@param  string $lang
@param  int    $id
@return array
@throws \Exception
JSON object with details for a specific category . All data used in update form .