repository = $permisos_module; parent::__construct(); } /** * Display a list of permisos_module. * * @return json */ public function index(PermisosModuleRequest $request) { $permisos_modules = $this->repository ->setPresenter('\\Church\\Church\\Repositories\\Presenter\\PermisosModuleListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->all(); $permisos_modules['code'] = 2000; return response()->json($permisos_modules) ->setStatusCode(200, 'INDEX_SUCCESS'); } /** * Display permisos_module. * * @param Request $request * @param Model PermisosModule * * @return Json */ public function show(PermisosModuleRequest $request, PermisosModule $permisos_module) { $permisos_module = $permisos_module->presenter(); $permisos_module['code'] = 2001; return response()->json($permisos_module) ->setStatusCode(200, 'SHOW_SUCCESS');; } /** * Show the form for creating a new permisos_module. * * @param Request $request * * @return json */ public function create(PermisosModuleRequest $request, PermisosModule $permisos_module) { $permisos_module = $permisos_module->presenter(); $permisos_module['code'] = 2002; return response()->json($permisos_module) ->setStatusCode(200, 'CREATE_SUCCESS'); } /** * Create new permisos_module. * * @param Request $request * * @return json */ public function store(PermisosModuleRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.api'); $permisos_module = $this->repository->create($attributes); $permisos_module = $permisos_module->presenter(); $permisos_module['code'] = 2004; return response()->json($permisos_module) ->setStatusCode(201, 'STORE_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4004, ])->setStatusCode(400, 'STORE_ERROR'); } } /** * Show permisos_module for editing. * * @param Request $request * @param Model $permisos_module * * @return json */ public function edit(PermisosModuleRequest $request, PermisosModule $permisos_module) { $permisos_module = $permisos_module->presenter(); $permisos_module['code'] = 2003; return response()-> json($permisos_module) ->setStatusCode(200, 'EDIT_SUCCESS');; } /** * Update the permisos_module. * * @param Request $request * @param Model $permisos_module * * @return json */ public function update(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $attributes = $request->all(); $permisos_module->update($attributes); $permisos_module = $permisos_module->presenter(); $permisos_module['code'] = 2005; return response()->json($permisos_module) ->setStatusCode(201, 'UPDATE_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4005, ])->setStatusCode(400, 'UPDATE_ERROR'); } } /** * Remove the permisos_module. * * @param Request $request * @param Model $permisos_module * * @return json */ public function destroy(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $t = $permisos_module->delete(); return response()->json([ 'message' => trans('messages.success.delete', ['Module' => trans('church::permisos_module.name')]), 'code' => 2006 ])->setStatusCode(202, 'DESTROY_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4006, ])->setStatusCode(400, 'DESTROY_ERROR'); } } }