repository = $tutorialcategory; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\Tutorial\Repositories\Criteria\TutorialcategoryResourceCriteria::class); } /** * Display a list of tutorialcategory. * * @return Response */ public function index(TutorialcategoryRequest $request) { return $this->repository ->setPresenter(\B2buy\Tutorial\Repositories\Presenter\TutorialcategoryPresenter::class) ->paginate(); } /** * Display tutorialcategory. * * @param Request $request * @param Model $tutorialcategory * * @return Response */ public function show(TutorialcategoryRequest $request, Tutorialcategory $tutorialcategory) { return $tutorialcategory->setPresenter(\B2buy\Tutorial\Repositories\Presenter\TutorialcategoryListPresenter::class); ; } /** * Create new tutorialcategory. * * @param Request $request * * @return Response */ public function store(TutorialcategoryRequest $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('tutorial::tutorialcategory.name')]); $code = 204; $status = 'success'; $url = guard_url('tutorial/tutorialcategory/' . $tutorialcategory->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('tutorial/tutorialcategory'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the tutorialcategory. * * @param Request $request * @param Model $tutorialcategory * * @return Response */ public function update(TutorialcategoryRequest $request, Tutorialcategory $tutorialcategory) { try { $data = $request->all(); $tutorialcategory->update($data); $message = trans('messages.success.updated', ['Module' => trans('tutorial::tutorialcategory.name')]); $code = 204; $status = 'success'; $url = guard_url('tutorial/tutorialcategory/' . $tutorialcategory->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('tutorial/tutorialcategory/' . $tutorialcategory->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the tutorialcategory. * * @param Model $tutorialcategory * * @return Response */ public function destroy(TutorialcategoryRequest $request, Tutorialcategory $tutorialcategory) { try { $tutorialcategory->delete(); $message = trans('messages.success.deleted', ['Module' => trans('tutorial::tutorialcategory.name')]); $code = 202; $status = 'success'; $url = guard_url('tutorial/tutorialcategory/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('tutorial/tutorialcategory/' . $tutorialcategory->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); } }