repository = $actiontypecategory; } /** * Display a list of actiontypecategory. * * @return Response */ public function index(ActiontypecategoryAdminRequest $request) { $actiontypecategories = $this->repository->setPresenter('\\Fegerer\\AppTest\\Repositories\\Presenter\\ActiontypecategoryListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this ->theme->prependTitle(trans('app_test::actiontypecategory.names').' :: '); $view = $this->theme->of('app_test::admin.actiontypecategory.index')->render(); $this->responseCode = 200; $this->responseMessage = trans('messages.success.loaded', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseData = $actiontypecategories['data']; $this->responseMeta = $actiontypecategories['meta']; $this->responseView = $view; $this->responseRedirect = ''; return $this->respond($request); } /** * Display actiontypecategory. * * @param Request $request * @param int $id * * @return Response */ public function show(ActiontypecategoryAdminRequest $request, Actiontypecategory $actiontypecategory) { if (!$actiontypecategory->exists) { $this->responseCode = 404; $this->responseMessage = trans('messages.success.notfound', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseView = view('app_test::admin.actiontypecategory.new'); return $this -> respond($request); } Form::populate($actiontypecategory); $this->responseCode = 200; $this->responseMessage = trans('messages.success.loaded', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseData = $actiontypecategory; $this->responseView = view('app_test::admin.actiontypecategory.show', compact('actiontypecategory')); return $this -> respond($request); } /** * Show the form for creating a new actiontypecategory. * * @param Request $request * * @return Response */ public function create(ActiontypecategoryAdminRequest $request) { $actiontypecategory = $this->repository->newInstance([]); Form::populate($actiontypecategory); $this->responseCode = 200; $this->responseMessage = trans('messages.success.loaded', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseData = $actiontypecategory; $this->responseView = view('app_test::admin.actiontypecategory.create', compact('actiontypecategory')); return $this -> respond($request); } /** * Create new actiontypecategory. * * @param Request $request * * @return Response */ public function store(ActiontypecategoryAdminRequest $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->responseData = $actiontypecategory; $this->responseMeta = ''; $this->responseRedirect = trans_url('/admin/app_test/actiontypecategory/'.$actiontypecategory->getRouteKey()); $this->responseView = view('app_test::admin.actiontypecategory.create', compact('actiontypecategory')); return $this -> respond($request); } catch (Exception $e) { $this->responseCode = 400; $this->responseMessage = $e->getMessage(); return $this -> respond($request); } } /** * Show actiontypecategory for editing. * * @param Request $request * @param int $id * * @return Response */ public function edit(ActiontypecategoryAdminRequest $request, Actiontypecategory $actiontypecategory) { Form::populate($actiontypecategory); $this->responseCode = 200; $this->responseMessage = trans('messages.success.loaded', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseData = $actiontypecategory; $this->responseView = view('app_test::admin.actiontypecategory.edit', compact('actiontypecategory')); return $this -> respond($request); } /** * Update the actiontypecategory. * * @param Request $request * @param int $id * * @return Response */ public function update(ActiontypecategoryAdminRequest $request, Actiontypecategory $actiontypecategory) { try { $attributes = $request->all(); $actiontypecategory->update($attributes); $this->responseCode = 204; $this->responseMessage = trans('messages.success.updated', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseData = $actiontypecategory; $this->responseRedirect = trans_url('/admin/app_test/actiontypecategory/'.$actiontypecategory->getRouteKey()); return $this -> respond($request); } catch (Exception $e) { $this->responseCode = 400; $this->responseMessage = $e->getMessage(); $this->responseRedirect = trans_url('/admin/app_test/actiontypecategory/'.$actiontypecategory->getRouteKey()); return $this -> respond($request); } } /** * Remove the actiontypecategory. * * @param int $id * * @return Response */ public function destroy(ActiontypecategoryAdminRequest $request, Actiontypecategory $actiontypecategory) { try { $t = $actiontypecategory->delete(); $this->responseCode = 202; $this->responseMessage = trans('messages.success.deleted', ['Module' => trans('app_test::actiontypecategory.name')]); $this->responseRedirect = trans_url('/admin/app_test/actiontypecategory/0'); return $this -> respond($request); } catch (Exception $e) { $this->responseCode = 400; $this->responseMessage = $e->getMessage(); $this->responseRedirect = trans_url('/admin/app_test/actiontypecategory/'.$actiontypecategory->getRouteKey()); return $this -> respond($request); } } }