Exemplo n.º 1
0
 public function eliminar($idOrg)
 {
     $vdt = new Validate\QuickValidator(array($this, 'notFound'));
     $vdt->test($idOrg, new Validate\Rule\NumNatural());
     $organismo = Organismo::findOrFail($idOrg);
     if ($organismo->funcionarios_count > 0) {
         echo 'lala1';
         throw new TurnbackException('Para eliminar un organismo no debe haber funcionarios dentro de este.');
     }
     $organismo->delete();
     AdminlogCtrl::createLog('', 3, 'del', $this->session->user('id'), $organismo);
     $this->flash('success', 'El organismo fue eliminado exitosamente.');
     $this->redirectTo('shwAdmOrganis');
 }
Exemplo n.º 2
0
 public function verifCiudadano()
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('entrantes', new Validate\Rule\Regex('/^\\[\\d+(?:,\\d+)*\\]$/'));
     $req = $this->request;
     if (!$vdt->validate($req->post())) {
         throw new TurnbackException('Configuración inválida.');
     }
     $entrantes = json_decode($vdt->getData('entrantes'));
     Usuario::whereIn('id', $entrantes)->whereNull('verified_at')->increment('puntos', 100, array('verified_at' => Carbon\Carbon::now()));
     foreach ($entrantes as $entrante) {
         $log = AdminlogCtrl::createLog('', 7, 'new', $this->session->user('id'), $entrante, 'Usuario');
         NotificacionCtrl::createNotif($entrante, $log);
     }
     $this->flash('success', 'Se han verificado los ciudadanos seleccionados exitosamente.');
     $this->redirectTo('shwAdmVrfUsuario');
 }
Exemplo n.º 3
0
 public function cambiarPoder($idPat)
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('idPat', new Validate\Rule\NumNatural())->addRule('poderes', new Validate\Rule\Regex('/^\\[\\d*(?:,\\d+)*\\]$/'));
     $req = $this->request;
     $data = array_merge(array('idPat' => $idPat), $req->post());
     if (!$vdt->validate($data)) {
         throw new TurnbackException($vdt->getErrors());
     }
     $patrulla = Patrulla::findOrFail($idPat);
     $poderes = json_decode($vdt->getData('poderes'));
     $patrulla->poderes()->sync($poderes);
     AdminlogCtrl::createLog(implode(',', $poderes), 5, 'pod', $this->session->user('id'), $patrulla);
     $this->flash('success', 'Los permisos del grupo de moderación fueron modificados exitosamente.');
     $this->redirectTo('shwAdmPatrull');
 }