repository = $portfolio__category; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\PortfolioCategory\Repositories\Criteria\PortfolioCategoryResourceCriteria::class); } /** * Display a list of portfolio__category. * * @return Response */ public function index(PortfolioCategoryRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\PortfolioCategory\Repositories\Presenter\PortfolioCategoryPresenter::class) ->$function(); } $portfolio__categories = $this->repository->paginate(); return $this->response->title(trans('portfolio_category::portfolio__category.names')) ->view('portfolio_category::portfolio__category.index', true) ->data(compact('portfolio__categories')) ->output(); } /** * Display portfolio__category. * * @param Request $request * @param Model $portfolio__category * * @return Response */ public function show(PortfolioCategoryRequest $request, PortfolioCategory $portfolio__category) { if ($portfolio__category->exists) { $view = 'portfolio_category::portfolio__category.show'; } else { $view = 'portfolio_category::portfolio__category.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio_category::portfolio__category.name')) ->data(compact('portfolio__category')) ->view($view, true) ->output(); } /** * Show the form for creating a new portfolio__category. * * @param Request $request * * @return Response */ public function create(PortfolioCategoryRequest $request) { $portfolio__category = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('portfolio_category::portfolio__category.name')) ->view('portfolio_category::portfolio__category.create', true) ->data(compact('portfolio__category')) ->output(); } /** * Create new portfolio__category. * * @param Request $request * * @return Response */ public function store(PortfolioCategoryRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $portfolio__category = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('portfolio_category::portfolio__category.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio_category/portfolio__category/' . $portfolio__category->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/portfolio_category/portfolio__category')) ->redirect(); } } /** * Show portfolio__category for editing. * * @param Request $request * @param Model $portfolio__category * * @return Response */ public function edit(PortfolioCategoryRequest $request, PortfolioCategory $portfolio__category) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio_category::portfolio__category.name')) ->view('portfolio_category::portfolio__category.edit', true) ->data(compact('portfolio__category')) ->output(); } /** * Update the portfolio__category. * * @param Request $request * @param Model $portfolio__category * * @return Response */ public function update(PortfolioCategoryRequest $request, PortfolioCategory $portfolio__category) { try { $attributes = $request->all(); $portfolio__category->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio_category::portfolio__category.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio_category/portfolio__category/' . $portfolio__category->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio_category/portfolio__category/' . $portfolio__category->getRouteKey())) ->redirect(); } } /** * Remove the portfolio__category. * * @param Model $portfolio__category * * @return Response */ public function destroy(PortfolioCategoryRequest $request, PortfolioCategory $portfolio__category) { try { $portfolio__category->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio_category::portfolio__category.name')])) ->code(202) ->status('success') ->url(guard_url('portfolio_category/portfolio__category/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio_category/portfolio__category/' . $portfolio__category->getRouteKey())) ->redirect(); } } /** * Remove multiple portfolio__category. * * @param Model $portfolio__category * * @return Response */ public function delete(PortfolioCategoryRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio_category::portfolio__category.name')])) ->status("success") ->code(202) ->url(guard_url('portfolio_category/portfolio__category')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/portfolio_category/portfolio__category')) ->redirect(); } } /** * Restore deleted portfolio__categories. * * @param Model $portfolio__category * * @return Response */ public function restore(PortfolioCategoryRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('portfolio_category::portfolio__category.name')])) ->status("success") ->code(202) ->url(guard_url('/portfolio_category/portfolio__category')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/portfolio_category/portfolio__category/')) ->redirect(); } } }