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
});
示例#2
0
                break;
            case "applicationSubCategory":
                $category = $datos[$i]['value'];
                break;
            case "screenshot":
                $screenshot = $datos[$i]['value'];
                break;
            case "datePublished":
                $date = $datos[$i]['value'];
                break;
            case "embedUrl":
                $embedUrl = $datos[$i]['value'];
                break;
        }
    }
    $videogame = new Videogame();
    $videogame->name = $name;
    $videogame->description = $desc;
    $videogame->gamePlatform = $plataf;
    $videogame->applicationSubCategory = $category;
    $videogame->screenshot = $screenshot;
    $videogame->datePublished = $date;
    $videogame->embedUrl = $embedUrl;
    $videogame->save();
    // Mostramos la vista
    $app->render('videogame_template.php');
});
//Actualizar videojuego
$app->put('/videogames/:id', function ($id) use($app) {
    // Creamos un objeto collection + json con el libro pasado como parámetro
    // Obtenemos el objeto request, que representa la petición HTTP
    $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'];
示例#4
0
    }
    public function mostrarjogos()
    {
        echo "Esses são os jogos para o console:";
        $this->pula();
        foreach ($this->listajogos as $jogo) {
            echo $jogo;
            $this->pula();
        }
    }
    public function __construct($nome, $preco, $wats, $listajogos = "")
    {
        $this->setNome($nome);
        $this->setValor($preco);
        $this->setConsumo($wats);
        $this->setListajogos($listajogos);
    }
}
$nokia = new Celular("Nokia", 400, 200, 20);
echo "celular criado\n";
$jogos = array("Mario", "Pokemon", "Wii sports");
$wii = new Videogame("Wii", 800, 300, $jogos);
echo "videogame criado\n";
$nokia->exibirInformaces();
$wii->exibirInformaces();
$senha = 123456;
$salt = "hdasuidhasuidh;dhasuidhasi;dashuidhas";
$salt_unico = "duiasduiash";
$senha_md5 = md5($senha . $salt . $salt_unico);
echo $senha_md5;
//@TODO ....