public static function getUserByUsernameAndPassword($username, $password)
 {
     if (is_null($username) || is_null($password)) {
         return null;
     }
     $query = "SELECT * FROM user WHERE deleted_on = 0 AND username = :username AND password = :password";
     $params = array("username" => $username, "password" => User::hashPassword($password));
     $st = static::db()->prepare($query);
     $st->execute($params);
     $results = $st->fetchAll(\PDO::FETCH_ASSOC);
     if (empty($results)) {
         return null;
     }
     $user = new User();
     $user->hydrate($results[0]);
     return $user;
 }
use Syndicate\Repositories\TimezoneRepository;
$app->get('/user/list', function (Request $request, Response $response) use($app) {
    $user_collection = UserRepository::getAllUsers();
    if (empty($user_collection)) {
        $new_response = $response->withStatus(404);
        $new_response->getBody()->write("No users found");
        return $new_response;
    }
    $response->getBody()->write(json_encode($user_collection));
    return $response;
});
$save_user = function (Request $request, Response $response) {
    $parser = new RequestParser($request);
    $data = $parser->getData();
    $user = new User();
    $user->hydrate($data);
    if (!empty($data['password'])) {
        $user->setPassword($data['password']);
    }
    $errors = $user->validateData();
    if (!empty($errors)) {
        $new_response = $response->withStatus(400);
        $r = array("errors" => $errors);
        $new_response->getBody()->write(json_encode($r));
        return $new_response;
    }
    $count = UserRepository::saveUser($user);
    $response->getBody()->write(json_encode($user));
    return $response;
};
$app->post('/user/save', $save_user);