mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +02:00
40 lines
No EOL
1 KiB
PHP
40 lines
No EOL
1 KiB
PHP
<?php
|
|
|
|
use Reflect\Path;
|
|
use Reflect\Response;
|
|
use ReflectRules\Type;
|
|
use ReflectRules\Rules;
|
|
use ReflectRules\Ruleset;
|
|
|
|
use VLW\API\Databases\VLWdb\{
|
|
VLWdb,
|
|
Databases
|
|
};
|
|
use VLW\API\Databases\VLWdb\Models\Playground\Coffee\CoffeeModel;
|
|
|
|
require_once Path::root("src/databases/VLWdb.php");
|
|
require_once Path::root("src/databases/models/Playground/Coffee/Coffee.php");
|
|
|
|
class GET_PlaygroundCoffee extends VLWdb {
|
|
protected Ruleset $ruleset;
|
|
|
|
public function __construct() {
|
|
$this->ruleset = new Ruleset(strict: true);
|
|
|
|
parent::__construct(Databases::PLAYGROUND, $this->ruleset);
|
|
}
|
|
|
|
public function main(): Response {
|
|
$result = $this->db
|
|
->for(CoffeeModel::TABLE)
|
|
->order([CoffeeModel::ID->value => "DESC"])
|
|
->select([
|
|
CoffeeModel::ID->value
|
|
]);
|
|
|
|
return $result->num_rows > 0
|
|
// Return entries as sequential array of integer timestamps
|
|
? new Response(array_map(fn(array $value): int => $value[0], $result->fetch_all(MYSQLI_NUM)))
|
|
: new Response([], 404);
|
|
}
|
|
} |