public function modificar($idPro) { $vdt = new Validate\QuickValidator(array($this, 'notFound')); $vdt->test($idPro, new Validate\Rule\NumNatural()); $propuesta = Propuesta::with(array('contenido', 'votos'))->findOrFail($idPro); $contenido = $propuesta->contenido; $usuario = $this->session->getUser(); $req = $this->request; $vdt = $this->validarPropuesta($req->post()); if ($vdt->getData('referido')) { $referido = Contenido::find($vdt->getData('referido')); if (is_null($referido) || $referido->contenible_type != 'Problematica') { throw new TurnbackException('La problematica asociada no existe.'); } } $propuesta->cuerpo = $vdt->getData('cuerpo'); $propuesta->save(); $contenido->titulo = $vdt->getData('titulo'); $contenido->categoria_id = $vdt->getData('categoria'); $contenido->referido_id = $vdt->getData('referido'); $contenido->save(); TagCtrl::updateTags($contenido, TagCtrl::getTagIds($vdt->getData('tags'))); $log = UserlogCtrl::createLog('modPropues', $usuario->id, $propuesta); NotificacionCtrl::createNotif($propuesta->votos->lists('usuario_id'), $log); $this->flash('success', 'Los datos de la propuesta fueron modificados exitosamente.'); $this->redirectTo('shwPropues', array('idPro' => $idPro)); }