Exemplo n.º 1
0
Arquivo: index.php Projeto: TM30/api
     /*$role = intval($role);*/
     $password = $app->request->post('password');
     $fieldsToUpdate = array();
     if ($username) {
         $fieldsToUpdate['name'] = $username;
     }
     if ($email) {
         $fieldsToUpdate['email'] = $email;
     }
     if ($role) {
         $fieldsToUpdate['role'] = $role;
     }
     if ($password) {
         $fieldsToUpdate['password'] = $password;
     }
     $userController->updateUser($fieldsToUpdate, intval($id));
     file_put_contents('users.json', json_encode($userController->fetchAllUsers()));
     echo json_encode(array('message' => "user updated successfully.."));
 });
 $app->delete('/user/:id', function ($id) use($app, $userController) {
     $userController->removeUser(intval($id));
     file_put_contents('users.json', json_encode($userController->fetchAllUsers()));
     echo json_encode(array('message' => "User Deleted Successfully..."));
 });
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
 //PLATFORMS
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
 $app->get("/platforms", function () use($app, $platformController) {
     if (file_exists("platforms.json")) {
         echo file_get_contents('platforms.json');
         return;