repository = $categories; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Game\Game\Repositories\Criteria\CategoriesResourceCriteria::class); } /** * Display a list of categories. * * @return Response */ public function index(CategoriesRequest $request) { return $this->repository ->setPresenter(\Game\Game\Repositories\Presenter\CategoriesPresenter::class) ->paginate(); } /** * Display categories. * * @param Request $request * @param Model $categories * * @return Response */ public function show(CategoriesRequest $request, Categories $categories) { return $categories->setPresenter(\Game\Game\Repositories\Presenter\CategoriesListPresenter::class); ; } /** * Create new categories. * * @param Request $request * * @return Response */ public function store(CategoriesRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('game::categories.name')]); $code = 204; $status = 'success'; $url = guard_url('game/categories/' . $categories->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('game/categories'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the categories. * * @param Request $request * @param Model $categories * * @return Response */ public function update(CategoriesRequest $request, Categories $categories) { try { $data = $request->all(); $categories->update($data); $message = trans('messages.success.updated', ['Module' => trans('game::categories.name')]); $code = 204; $status = 'success'; $url = guard_url('game/categories/' . $categories->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('game/categories/' . $categories->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the categories. * * @param Model $categories * * @return Response */ public function destroy(CategoriesRequest $request, Categories $categories) { try { $categories->delete(); $message = trans('messages.success.deleted', ['Module' => trans('game::categories.name')]); $code = 202; $status = 'success'; $url = guard_url('game/categories/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('game/categories/' . $categories->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }