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