repository = $permisos_module; parent::__construct(); } /** * Display a list of permisos_module. * * @return Response */ public function index(PermisosModuleRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('church::permisos_module.names').' :: '); return $this->theme->of('church::admin.permisos_module.index')->render(); } /** * Display a list of permisos_module. * * @return Response */ public function getJson(PermisosModuleRequest $request) { $pageLimit = $request->input('pageLimit'); $permisos_modules = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Church\\Church\\Repositories\\Presenter\\PermisosModuleListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $permisos_modules['recordsTotal'] = $permisos_modules['meta']['pagination']['total']; $permisos_modules['recordsFiltered'] = $permisos_modules['meta']['pagination']['total']; $permisos_modules['request'] = $request->all(); return response()->json($permisos_modules, 200); } /** * Display permisos_module. * * @param Request $request * @param Model $permisos_module * * @return Response */ public function show(PermisosModuleRequest $request, PermisosModule $permisos_module) { if (!$permisos_module->exists) { return response()->view('church::admin.permisos_module.new', compact('permisos_module')); } Form::populate($permisos_module); return response()->view('church::admin.permisos_module.show', compact('permisos_module')); } /** * Show the form for creating a new permisos_module. * * @param Request $request * * @return Response */ public function create(PermisosModuleRequest $request) { $permisos_module = $this->repository->newInstance([]); Form::populate($permisos_module); return response()->view('church::admin.permisos_module.create', compact('permisos_module')); } /** * Create new permisos_module. * * @param Request $request * * @return Response */ public function store(PermisosModuleRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $permisos_module = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('church::permisos_module.name')]), 'code' => 204, 'redirect' => trans_url('/admin/church/permisos_module/'.$permisos_module->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show permisos_module for editing. * * @param Request $request * @param Model $permisos_module * * @return Response */ public function edit(PermisosModuleRequest $request, PermisosModule $permisos_module) { Form::populate($permisos_module); return response()->view('church::admin.permisos_module.edit', compact('permisos_module')); } /** * Update the permisos_module. * * @param Request $request * @param Model $permisos_module * * @return Response */ public function update(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $attributes = $request->all(); $permisos_module->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('church::permisos_module.name')]), 'code' => 204, 'redirect' => trans_url('/admin/church/permisos_module/'.$permisos_module->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/church/permisos_module/'.$permisos_module->getRouteKey()), ], 400); } } /** * Remove the permisos_module. * * @param Model $permisos_module * * @return Response */ public function destroy(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $t = $permisos_module->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('church::permisos_module.name')]), 'code' => 202, 'redirect' => trans_url('/admin/church/permisos_module/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/church/permisos_module/'.$permisos_module->getRouteKey()), ], 400); } } }