repository = $permisos_module; $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->pushCriteria(new \Church\Church\Repositories\Criteria\PermisosModuleUserCriteria()); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(PermisosModuleRequest $request) { $permisos_modules = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('church::permisos_module.names')); return $this->theme->of('church::user.permisos_module.index', compact('permisos_modules'))->render(); } /** * Display the specified resource. * * @param Request $request * @param PermisosModule $permisos_module * * @return Response */ public function show(PermisosModuleRequest $request, PermisosModule $permisos_module) { Form::populate($permisos_module); return $this->theme->of('church::user.permisos_module.show', compact('permisos_module'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(PermisosModuleRequest $request) { $permisos_module = $this->repository->newInstance([]); Form::populate($permisos_module); $this->theme->prependTitle(trans('church::permisos_module.names')); return $this->theme->of('church::user.permisos_module.create', compact('permisos_module'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(PermisosModuleRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $permisos_module = $this->repository->create($attributes); return redirect(trans_url('/user/church/permisos_module')) -> with('message', trans('messages.success.created', ['Module' => trans('church::permisos_module.name')])) -> with('code', 201); } 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 PermisosModule $permisos_module * * @return Response */ public function edit(PermisosModuleRequest $request, PermisosModule $permisos_module) { Form::populate($permisos_module); $this->theme->prependTitle(trans('church::permisos_module.names')); return $this->theme->of('church::user.permisos_module.edit', compact('permisos_module'))->render(); } /** * Update the specified resource. * * @param Request $request * @param PermisosModule $permisos_module * * @return Response */ public function update(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $this->repository->update($request->all(), $permisos_module->getRouteKey()); return redirect(trans_url('/user/church/permisos_module')) ->with('message', trans('messages.success.updated', ['Module' => trans('church::permisos_module.name')])) ->with('code', 204); } 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(PermisosModuleRequest $request, PermisosModule $permisos_module) { try { $this->repository->delete($permisos_module->getRouteKey()); return redirect(trans_url('/user/church/permisos_module')) ->with('message', trans('messages.success.deleted', ['Module' => trans('church::permisos_module.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }