vlw.se/src/Database/Models/Coffee/Stats.php
Victor Westerlund f4279c0343 feat: add coffee stats endpoints and counter to about page (#28)
This PR refactors some texts on the about page (again), and also a adds two new endpoints for a database table that I have now made public that tracks the coffee cups I've had. The endpoint itself is not public now but I might make a page (something like `/about/coffee`) that presents it in a not-ugly way.

Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/28
2025-03-13 15:16:53 +00:00

32 lines
No EOL
795 B
PHP

<?php
namespace VLW\Database\Models\Coffee;
use \VV;
use VLW\API\Endpoints;
use VLW\Database\Models\Model;
use VLW\Database\Tables\Coffee\StatsTable;
require_once VV::root("src/API/Endpoints.php");
require_once VV::root("src/Database/Models/Model.php");
require_once VV::root("src/Database/Tables/Coffee/Stats.php");
require_once VV::root("src/Database/Models/Coffee/Stats.php");
class Stats extends Model {
public function __construct() {
parent::__construct(Endpoints::COFFEE_STATS);
}
public static function all(array $params = []): array {
return [];
}
public function week(): int {
return $this->get(StatsTable::COUNT_WEEK->value) ?? 0;
}
public function week_average(): int {
return $this->get(StatsTable::COUNT_WEEK_AVERAGE->value) ?? 0;
}
}