repository = $actiontypecategory; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(ActiontypecategoryUserRequest $request) { $this->repository->pushCriteria(new \Lavalite\AppTest\Repositories\Criteria\ActiontypecategoryUserCriteria()); $actiontypecategories = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('app_test::actiontypecategory.names').' :: '); return $this->theme->of('app_test::user.actiontypecategory.index', compact('actiontypecategories'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Actiontypecategory $actiontypecategory * * @return Response */ public function show(ActiontypecategoryUserRequest $request, Actiontypecategory $actiontypecategory) { Form::populate($actiontypecategory); return $this->theme->of('app_test::user.actiontypecategory.show', compact('actiontypecategory'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(ActiontypecategoryUserRequest $request) { $actiontypecategory = $this->repository->newInstance([]); Form::populate($actiontypecategory); return $this->theme->of('app_test::user.actiontypecategory.create', compact('actiontypecategory'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(ActiontypecategoryUserRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $actiontypecategory = $this->repository->create($attributes); $this->responseCode = 201; $this->responseMessage = trans('messages.success.created', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseRedirect = trans_url('/user/app_test/actiontypecategory'); return $this -> respond($request); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param Actiontypecategory $actiontypecategory * * @return Response */ public function edit(ActiontypecategoryUserRequest $request, Actiontypecategory $actiontypecategory) { Form::populate($actiontypecategory); return $this->theme->of('app_test::user.actiontypecategory.edit', compact('actiontypecategory'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Actiontypecategory $actiontypecategory * * @return Response */ public function update(ActiontypecategoryUserRequest $request, Actiontypecategory $actiontypecategory) { try { $this->repository->update($request->all(), $actiontypecategory->getRouteKey()); $this->responseCode = 204; $this->responseMessage = trans('messages.success.updated', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseRedirect = trans_url('/user/app_test/actiontypecategory'); return $this -> respond($request); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(ActiontypecategoryUserRequest $request, Actiontypecategory $actiontypecategory) { try { $this->repository->delete($actiontypecategory->getRouteKey()); $this->responseCode = 204; $this->responseMessage = trans('messages.success.deleted', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseRedirect = trans_url('/user/app_test/actiontypecategory'); return $this -> respond($request); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }