{"action":"closed","issue":{"url":"https://api.github.com/repos/lametro/programacion-4-2015/issues/45","labels_url":"https://api.github.com/repos/lametro/programacion-4-2015/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/lametro/programacion-4-2015/issues/45/comments","events_url":"https://api.github.com/repos/lametro/programacion-4-2015/issues/45/events","html_url":"https://github.com/lametro/programacion-4-2015/issues/45","id":114663004,"number":45,"title":"Error para crear un usuario (WARNING: Illegal string offset 'name')","user":{"login":"fedemiguez","id":13700491,"avatar_url":"https://avatars.githubusercontent.com/u/13700491?v=3","gravatar_id":"","url":"https://api.github.com/users/fedemiguez","html_url":"https://github.com/fedemiguez","followers_url":"https://api.github.com/users/fedemiguez/followers","following_url":"https://api.github.com/users/fedemiguez/following{/other_user}","gists_url":"https://api.github.com/users/fedemiguez/gists{/gist_id}","starred_url":"https://api.github.com/users/fedemiguez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedemiguez/subscriptions","organizations_url":"https://api.github.com/users/fedemiguez/orgs","repos_url":"https://api.github.com/users/fedemiguez/repos","events_url":"https://api.github.com/users/fedemiguez/events{/privacy}","received_events_url":"https://api.github.com/users/fedemiguez/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-02T19:06:50Z","updated_at":"2015-11-03T04:52:51Z","closed_at":"2015-11-03T04:52:51Z","body":"Hola profe, estamos teniendo un error a la hora de crear un usuario es solo con esa consulta, el problema existe desde la app y desde el postman, antes funcionaba y despues de modificar la api empezo a tirar el problema\r\n\r\n![image](https://cloud.githubusercontent.com/assets/13700491/10891126/e6356cd0-817a-11e5-8bc9-26a3143412e8.png)\r\n\r\n\r\naca el error en postman \r\n\r\n![image](https://cloud.githubusercontent.com/assets/13700491/10891204/49b13bfe-817b-11e5-998c-c5d8df4b3897.png)\r\n\r\n\r\naca dejo el codigo de la api\r\n\r\n<?php\r\n\r\n\r\nini_set('display_errors',1);\r\nini_set('display_startup_errors',1);\r\nerror_reporting(-1);\r\n\r\nrequire 'vendor/autoload.php';\r\nrequire 'Models/User.php';\r\n\r\n\r\n$app = new \\Slim\\Slim();\r\n\r\n$app->config('databases', [\r\n    'default' => [\r\n        'driver'    => 'mysql',\r\n        'host'      => 'us-cdbr-iron-east-03.cleardb.net',\r\n        'database'  => 'heroku_b2562bab37645c3',\r\n        'username'  => 'bd90c798d775ac',\r\n        'password'  => '9221123b',\r\n        'charset'   => 'utf8',\r\n        'collation' => 'utf8_general_ci',\r\n        'prefix'    => ''\r\n    ]\r\n]);\r\n\r\n$app->add(new Zeuxisoo\\Laravel\\Database\\Eloquent\\ModelMiddleware);\r\n$app->view(new \\JsonApiView());\r\n$app->add(new \\JsonApiMiddleware());\r\n$app->add(new \\Slim\\Middleware\\ContentTypes());\r\n\r\n$app->options('/(:name+)', function() use ($app) {\r\n    $app->render(200,array('msg' => 'API SeJuega'));\r\n});\r\n\r\n$app->get('/', function () use ($app) {\r\n\t$app->render(200,array('msg' => 'API SeJuega'));\r\n});\r\n$app->get('/usuario', function () use ($app) {\r\n\t$db = $app->db->getConnection();\r\n\t$users = $db->table('users')->select('id', 'name')->get();\r\n\t$app->render(200,array('data' => $users));\r\n});\r\n$app->post('/usuario', function () use ($app) {\r\n\t$input = $app->request->getBody();\r\n\t$name = $input['name'];\r\n\tif(empty($name)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'name is required',\r\n        ));\r\n\t}\r\n\t$password = $input['password'];\r\n\tif(empty($password)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'password is required',\r\n        ));\r\n\t}\r\n\t$email = $input['email'];\r\n\tif(empty($email)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'email is required',\r\n        ));\r\n\t}\r\n    $user = new User();\r\n    $user->name = $name;\r\n    $user->password = $password;\r\n    $user->email = $email;\r\n    $user->save();\r\n    $app->render(200,array('data' => $user->toArray()));\r\n});\r\n$app->put('/usuario/:id', function ($id) use ($app) {\r\n\t$input = $app->request->getBody();\r\n\t\r\n\t$name = $input['name'];\r\n\tif(empty($name)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'name is required',\r\n        ));\r\n\t}\r\n\t$password = $input['password'];\r\n\tif(empty($password)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'password is required',\r\n        ));\r\n\t}\r\n\t$email = $input['email'];\r\n\tif(empty($email)){\r\n\t\t$app->render(500,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'email is required',\r\n        ));\r\n\t}\r\n\t$user = User::find($id);\r\n\tif(empty($user)){\r\n\t\t$app->render(404,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'user not found',\r\n        ));\r\n\t}\r\n    $user->name = $name;\r\n    $user->password = $password;\r\n    $user->email = $email;\r\n    $user->save();\r\n    $app->render(200,array('data' => $user->toArray()));\r\n});\r\n$app->get('/usuario/:id', function ($id) use ($app) {\r\n\t$user = User::find($id);\r\n\tif(empty($user)){\r\n\t\t$app->render(404,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'user not found',\r\n        ));\r\n\t}\r\n\t$app->render(200,array('data' => $user->toArray()));\r\n});\r\n$app->delete('/usuario/:id', function ($id) use ($app) {\r\n\t$user = User::find($id);\r\n\tif(empty($user)){\r\n\t\t$app->render(404,array(\r\n\t\t\t'error' => TRUE,\r\n            'msg'   => 'user not found',\r\n        ));\r\n\t}\r\n\t$user->delete();\r\n\t$app->render(200);\r\n});\r\n?>"}}