I'm creating a simple REST API signin and got this error in success() method: Uncaught Error: Call to undefined method Phalcon\Mvc\Model\Resultset\Simple::success() in F:\xampp\htdocs\phalcon-api\index.php:101 The code is given below:
<?php
use Phalcon\Loader; use Phalcon\Mvc\Micro; use Phalcon\Di\FactoryDefault; use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql; use Phalcon\Http\Response;
// Post API Signin
$app->post(
"/signin",
function () use ($app) {
$robot = $app->request->getJsonRawBody();
$phql = "SELECT * FROM Store\\Toys\\user WHERE email = :email: AND password = :password:";
$status = $app->modelsManager->executeQuery(
$phql,
[
"email" => $robot->email,
"password" => $robot->password,
]
);
// Create a response
$response = new Response();
// Check if the insertion was successful
if ($status->success() === true) {
// Change the HTTP status
$response->setStatusCode(201, "Created");
$robot->u_id = $status->getModel()->u_id;
$response->setJsonContent(
[
"status" => "OK",
"data" => $robot,
]
);
} else {
// Change the HTTP status
$response->setStatusCode(409, "Conflict");
// Send errors to the client
$errors = [];
foreach ($status->getMessages() as $message) {
$errors[] = $message->getMessage();
}
$response->setJsonContent(
[
"status" => "ERROR",
"messages" => $errors,
]
);
}
return $response;
}
);
$app->handle();