Display category.

@param Request $request
@param Model   $category

@return Response
338189
public function show(CategoryRequest $request, Category $category)
    {

        if ($category->exists) {
            $view = 'block::admin.category.show';
        } else {
            $view = 'block::admin.category.new';
        }

        return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::category.name'))
            ->data(compact('category'))
            ->view($view)
            ->output();
    }
1167546
public function index(CategoryRequest $request)
    {

        if ($this->response->typeIs('json')) {
            $pageLimit = $request->input('pageLimit');
            $data      = $this->repository
                ->setPresenter(\Litecms\Block\Repositories\Presenter\CategoryListPresenter::class)
                ->getDataTable($pageLimit);
            return $this->response
                ->data($data)
                ->output();
        }

        $categories = $this->repository->paginate();

        return $this->response->setMetaTitle(trans('block::category.names'))
            ->view('block::admin.category.index')
            ->data(compact('categories'))
            ->output();
    }
1233185
public function display($category)
    {

        $view = (View::exists("block::{$category}")) ? "block::{$category}" : "block::default";
        
        $category = $this->category
            ->scopeQuery(function ($query) use ($category) {
                return $query->with('blocks')->whereSlug($category);
            })->first();

        $blocks = $category->blocks;
        return view($view, compact('blocks', 'category'))->render();
    }
369132
public function update(DocumentCategory $category)
    {
        $attributes = request()->validate(DocumentCategory::$rules, DocumentCategory::$messages);

        $category = $this->updateEntry($category, $attributes);

        return redirect_to_resource();
    }
515274
public function createCategory(Request $request)
    {
        $this->validate(
            $request,
            [
                'parent_category_id' => 'integer|exists:categories',
                'name'               => 'required',
                'slug'               => 'required',
            ]
        );

        $category = new Category();

        $category->parentCategoryId = $request->input('parent_category_id');
        $category->name = $request->input('name');
        $category->slug = $request->input('slug');

        $category->save();

        return redirect()->back()->withStatus(trans('mustard::admin.category_created'));
    }
630534
public function store(Request $request)
    {
        $this->validate($request, [
            'name'      => 'required',
            'color'     => 'required',
        ]);

        $category = new Category();
        $category->create(['name' => $request->name, 'color' => $request->color]);

        Session::flash('status', trans('ticketit::lang.category-name-has-been-created', ['name' => $request->name]));

        \Cache::forget('ticketit::categories');

        return redirect()->action('\Kordy\Ticketit\Controllers\CategoriesController@index');
    }
339274
public function store(CategoryGroup $categoryGroup, CategoryRequest $request): JsonResponse
    {
        $category = $categoryGroup->categories()->create(
            $request->only('icon')
        );

        foreach ($request->file('icons', []) as $key => $file) {
            if ($categoryGroup->hasFileIcon($key) && $file) {
                $category->icons()->create([
                    'key'  => $key,
                    'icon' => $file,
                ]);
            }
        }

        $this->modifySlugs($request);

        $category->storeTranslations(
            $request->input('translations')
        );

        if ($request->has('parent_id') && $parent = Category::find($request->input('parent_id'))) {
            $parent->appendNode($category);
        }

        dispatch(
            new RegenerateCategoryFullSlugs($category)
        );

        $this->clearCache();

        return response()->json([
            'state' => 'success',
        ]);
    }
1206641
public function cdeleteAction($categoryId, Request $request)
    {
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);

        $ids = array_filter(explode(',', $request->get('ids')));
        foreach ($ids as $id) {
            $keyword = $this->getKeywordRepository()->findById($id);
            $this->getKeywordManager()->delete($keyword, $category);
        }

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
1140395
public function setCategory(\Amulen\ClassificationBundle\Entity\Category $category = null)
    {
        $this->category = $category;

        return $this;
    }
1149187
public function insert (Request $request)
    {
        if ($this->category->categoryExist($request->input('title') , $request->input('model_type')))
            throw new CategoryException(trans('Categories::category.error-message.categoryExist'));

        $category = $this->category->newInstance($request->except('_token'));
        $slug = new Slugger($this->modelType);
        $category->slug = $slug->storeSlug($request->input('slug') , $request->input('title'));
        $category->model_type = $this->modelType;
        $category->save();

        return $category;

    }
590883
public function showAction(Category $category)
    {
        $deleteForm = $this->createDeleteForm($category);

        return array(
            'entity' => $category,
            'delete_form' => $deleteForm->createView(),
        );
    }
173768
public function showAction($slug)
    {
        $category = $this->getCategoryRepository()->retrieveActiveBySlug($slug);

        if (!$category) {
            throw $this->createNotFoundException('category doesnt exists');
        }

        return $this->render(
            'GenjFaqBundle:Category:show.html.twig',
            array(
                'category' => $category
            )
        );
    }
440120
public function listCategory($category_group_id)
    {
        $this->setCategoryGroup($category_group_id);
        $this->actionListCategory();

        $this->setTitleListCategory();
        $this->setBreadcrumbListCategory();
        $this->setFilterListCategory();
        $this->setPagerListCategory();

        $this->setData('categories', $this->getListCategory());
        $this->setData('category_group_id', $category_group_id);

        $this->outputListCategory();
    }
1321940
public function category(Category $category)
    {
        $this->_category = $category;

        $this->joinWith('categories');
        $this->andFilterWhere([$category::tableName().'.id' => $this->_category->id]);

        return $this;
    }
143710
def show_category(self):
        
        url = 'https://openapi.youku.com/v2/schemas/show/category.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
389852
public function putAction($categoryId, $keywordId, Request $request)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);

        if (!$keyword) {
            return $this->handleView($this->view(null, 404));
        }

        $force = $request->get('force');
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $keyword->setKeyword($request->get('keyword'));

        $keyword = $this->getKeywordManager()->save($keyword, $category, $force);

        $this->getEntityManager()->persist($keyword);
        $this->getEntityManager()->flush();

        return $this->handleView($this->view($keyword));
    }
478535
public function showAction(Request $request, $folderId)
    {
        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();
        $session = $request->getSession();

        // Check when user switches between thumb -and list view
        $viewMode = $request->query->get('viewMode');
        if ($viewMode && $viewMode == 'list-view') {
            $session->set('media-list-view', true);
        } elseif ($viewMode && $viewMode == 'thumb-view') {
            $session->remove('media-list-view');
        }

        /* @var MediaManager $mediaManager */
        $mediaManager = $this->get('kunstmaan_media.media_manager');

        /* @var Folder $folder */
        $folder = $em->getRepository('KunstmaanMediaBundle:Folder')->getFolder($folderId);

        $adminListConfigurator = new MediaAdminListConfigurator($em, $mediaManager, $folder, $request);
        $adminList = $this->get('kunstmaan_adminlist.factory')->createList($adminListConfigurator);
        $adminList->bindRequest($request);

        $sub = new Folder();
        $sub->setParent($folder);
        $subForm = $this->createForm(FolderType::class, $sub, array('folder' => $sub));

        $emptyForm = $this->createEmptyForm();

        $editForm = $this->createForm(FolderType::class, $folder, array('folder' => $folder));

        if ($request->isMethod('POST')) {
            $editForm->handleRequest($request);
            if ($editForm->isValid()) {
                $em->getRepository('KunstmaanMediaBundle:Folder')->save($folder);

                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('media.folder.show.success.text', array(
                        '%folder%' => $folder->getName(),
                    ))
                );

                return new RedirectResponse(
                    $this->generateUrl(
                        'KunstmaanMediaBundle_folder_show',
                        array('folderId' => $folderId)
                    )
                );
            }
        }

        return array(
            'foldermanager' => $this->get('kunstmaan_media.folder_manager'),
            'mediamanager' => $this->get('kunstmaan_media.media_manager'),
            'subform' => $subForm->createView(),
            'emptyform' => $emptyForm->createView(),
            'editform' => $editForm->createView(),
            'folder' => $folder,
            'adminlist' => $adminList,
            'type' => null,
        );
    }