From 0c645773bf56d273f3758423fa8c712e63dc6360 Mon Sep 17 00:00:00 2001 From: BrianAcuna Date: Tue, 25 Oct 2016 02:28:25 +0000 Subject: [PATCH 1/2] Agregar persona --- src/Users/UsersController.php | 38 ++++++++++++++++++++++++++++++-- views/Users/users.edit.html.twig | 2 +- views/Users/users.list.html.twig | 15 ++++++------- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/Users/UsersController.php b/src/Users/UsersController.php index 1af4c26..ef669c4 100644 --- a/src/Users/UsersController.php +++ b/src/Users/UsersController.php @@ -21,16 +21,32 @@ public function connect(Application $app) // obtiene el nombre de usuario de la sesión $user = $app['session']->get('user'); + $us = $app['session']->get('us'); + if(!isset($us)){ + $us = array( + array( + + 'nombre' =>'Brian', + 'apellido' => 'Acuña', + 'direccion' => 'cll 64' , + 'email' => 'briandc0208@gmail' , + 'telefono' => '2236301' + ) + ); + $app['session']->set('us',$us); + } + // ya ingreso un usuario ? if ( isset( $user ) && $user != '' ) { // muestra la plantilla return $app['twig']->render('Users/users.list.html.twig', array( - 'user' => $user + 'user' => $user, + 'us' => $us )); } else { // redirige el navegador a "/login" - return $app->redirect( $app['url_generator']->generate('login')); + return $app->redirect( $app['url_generator']->generate('login')); } // hace un bind @@ -57,6 +73,24 @@ public function connect(Application $app) // hace un bind })->bind('users-edit'); + $controller->post('/doagregarproducto', function(Request $request) use($app){ + + $us = $app ['session']->get('us'); + $us[] = array( + + 'nombre' => $request->get('nombre'), + 'apellido' => $request->get('apellido'), + 'direccion' => $request->get('direccion'), + 'email' => $request->get('email'), + 'telefono' => $request->get('telefono') + + ); + $app['session']->set('us', $us); + + return $app->redirect( $app['url_generator']->generate( 'users-list' )); + + })->bind('doagregarproducto'); + return $controller; } diff --git a/views/Users/users.edit.html.twig b/views/Users/users.edit.html.twig index d7415ab..13c0ba6 100644 --- a/views/Users/users.edit.html.twig +++ b/views/Users/users.edit.html.twig @@ -4,7 +4,7 @@ {% block body %} -
+
diff --git a/views/Users/users.list.html.twig b/views/Users/users.list.html.twig index 5c83264..306ca7a 100644 --- a/views/Users/users.list.html.twig +++ b/views/Users/users.list.html.twig @@ -20,19 +20,18 @@ Dirección Email Teléfono - Editar Borrar - +{% for u in us %} - Mohsin - Irshad - CB 106/107 Street # 11 Wah Cantt Islamabad Pakistan - isometric.mohsin@gmail.com - +923335586757 + {{ u.nombre }} + {{ u.apellido }} + {{ u.direccion }} + {{ u.email }} + {{ u.telefono }}

- + + + + diff --git a/views/Users/users.list.html.twig b/views/Users/users.list.html.twig index 306ca7a..c0a0cc3 100644 --- a/views/Users/users.list.html.twig +++ b/views/Users/users.list.html.twig @@ -8,46 +8,53 @@

- LIsta de Usuarios + Lista de Facultades
+ - - + - + + -{% for u in us %} + + {% for index, u in use %} + - - + - + -{% endfor %} + {% endfor %} +
ID NombreApellidoDirecciónDecano EmailTeléfonoSitio WebEditar Borrar
{{ u.id }} {{ u.nombre }}{{ u.apellido }}{{ u.direccion }}{{ u.decano }} {{ u.email }}{{ u.telefono }}{{ u.sitio }}

- + + +

- + + +

diff --git a/views/inicio.html.twig b/views/inicio.html.twig index 6d31648..bb3a15d 100644 --- a/views/inicio.html.twig +++ b/views/inicio.html.twig @@ -5,8 +5,8 @@ {% block body %}
-

Aplicación de Ejemplo

-

La mejor aplicación!

+

FACULTADES

+

Lista de facultades

{% endblock %} \ No newline at end of file diff --git a/views/layout.html.twig b/views/layout.html.twig index 94c0a3f..cc0ff76 100644 --- a/views/layout.html.twig +++ b/views/layout.html.twig @@ -41,8 +41,8 @@ Usuarios