case "description": $description = $item['value']; break; case "gamePlatform": $gamePlatform = $item['value']; break; case "applicationSubCategory": $applicationSubCategory = $item['value']; break; case "screenshot": $screenshot = $item['value']; break; case "embedUrl": $embedUrl = $item['value']; break; case "datePublished": $datePublished = $item['value']; break; } } $new_videogame = Videogame::find($id); $new_videogame["name"] = $name; $new_videogame["description"] = $description; $new_videogame["gamePlatform"] = $gamePlatform; $new_videogame["applicationSubCategory"] = $applicationSubCategory; $new_videogame["screenshot"] = $screenshot; $new_videogame["embedUrl"] = $embedUrl; $new_videogame["datePublished"] = $datePublished; $new_videogame->save(); //falta sacar codigo 200 de sucess });
$vg->screenshot = $screenshot; $vg->datePublished = $date; $vg->embedUrl = $embedUrl; $vg->save(); // Mostramos la vista $app->render('videogame_template.php'); }); /* Modificar un videojuego en concreto */ $app->put('/videogames/:name', function ($name) use($app) { // Creamos un objeto collection + json con el videojuego pasada como parámetro // Obtenemos el objeto request, que representa la petición HTTP $req = $app->request; // Obtenemos la ruta absoluta de este recurso $absUrl = $req->getScheme() . "://" . $req->getHost() . $req->getRootUri() . $req->getResourceUri(); // Obtenemos el videojuego de la base de datos a partir de su id y la convertimos del formato Json (el devuelto por Eloquent) a un array PHP $vg = \Videogame::find($name); //Código para peticiones de POST (creación de items) $body = $app->request->getBody(); $template = json_decode($body, true); $datos = $template['template']['data']; $longitud = count($datos); for ($i = 0; $i < $longitud; $i++) { switch ($datos[$i]['name']) { case "name": $name = $datos[$i]['value']; break; case "description": $desc = $datos[$i]['value']; break; case "gamePlatform": $plataf = $datos[$i]['value'];