Compare commits
No commits in common. "daf7250882064b118054a2c121cb787ae5638a2f" and "6b470a181d0138dc042951f3d4f3001e3ed8bc17" have entirely different histories.
daf7250882
...
6b470a181d
@ -819,6 +819,8 @@ class Model {
|
|||||||
$in = array_keys((new $className())->getVars());
|
$in = array_keys((new $className())->getVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db = static::db();
|
||||||
|
|
||||||
$search = static::bindValue($search);
|
$search = static::bindValue($search);
|
||||||
$where = [];
|
$where = [];
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ namespace Libs;
|
|||||||
class Request extends Neuron {
|
class Request extends Neuron {
|
||||||
public Neuron $get;
|
public Neuron $get;
|
||||||
public Neuron $post;
|
public Neuron $post;
|
||||||
public Neuron $put;
|
|
||||||
public Neuron $patch;
|
|
||||||
public Neuron $json;
|
public Neuron $json;
|
||||||
public Neuron $params;
|
public Neuron $params;
|
||||||
public string $path;
|
public string $path;
|
||||||
@ -33,21 +31,14 @@ class Request extends Neuron {
|
|||||||
$this->path = Router::currentPath();
|
$this->path = Router::currentPath();
|
||||||
$this->get = new Neuron($_GET);
|
$this->get = new Neuron($_GET);
|
||||||
$this->post = new Neuron($_POST);
|
$this->post = new Neuron($_POST);
|
||||||
$this->put = new Neuron();
|
|
||||||
$this->patch = new Neuron();
|
|
||||||
|
|
||||||
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
|
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
|
||||||
if ($contentType === "application/json")
|
if ($contentType === "application/json")
|
||||||
$this->json = new Neuron(
|
$this->json = new Neuron(
|
||||||
(object) json_decode(trim(file_get_contents("php://input")), false)
|
(object) json_decode(trim(file_get_contents("php://input")), false)
|
||||||
);
|
);
|
||||||
else {
|
else
|
||||||
$this->json = new Neuron();
|
$this->json = new Neuron();
|
||||||
if (in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH'])) {
|
|
||||||
parse_str(file_get_contents("php://input"), $input_vars);
|
|
||||||
$this->{strtolower($_SERVER['REQUEST_METHOD'])} = new Neuron($input_vars);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->params = new Neuron();
|
$this->params = new Neuron();
|
||||||
}
|
}
|
||||||
@ -59,10 +50,10 @@ class Request extends Neuron {
|
|||||||
*/
|
*/
|
||||||
public function validate(): mixed
|
public function validate(): mixed
|
||||||
{
|
{
|
||||||
$actual = match($_SERVER['REQUEST_METHOD']) {
|
if ($_SERVER['REQUEST_METHOD'] == 'GET')
|
||||||
'GET', 'DELETE' => $this->get,
|
$actual = $this->get;
|
||||||
default => $this->{strtolower($_SERVER['REQUEST_METHOD'])}
|
else
|
||||||
};
|
$actual = $this->post;
|
||||||
|
|
||||||
if (Validator::validateList(static::paramRules(), $this->params) &&
|
if (Validator::validateList(static::paramRules(), $this->params) &&
|
||||||
Validator::validateList(static::getRules(), $this->get ) &&
|
Validator::validateList(static::getRules(), $this->get ) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user