mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-14 05:13:46 +02:00
The PR is a huge refactor of all Reflect and Vegvisir code. I've merged the API and "Front-end" codebases together into the same root, this will allow for both Reflect and Vegvisir to use the same resources. Not only that, but I've also added proper database modeling with actual OOP inheritance for database tables. Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/23
43 lines
No EOL
1.2 KiB
PHP
43 lines
No EOL
1.2 KiB
PHP
<?php
|
|
|
|
namespace VLW\Database\Models\Work;
|
|
|
|
use \VV;
|
|
|
|
use VLW\API\Endpoints;
|
|
use VLW\Database\Models\Model;
|
|
use VLW\Database\Models\Work\Work;
|
|
use VLW\Database\Tables\Work\TimelineTable;
|
|
|
|
require_once VV::root("src/API/Endpoints.php");
|
|
require_once VV::root("src/Database/Models/Model.php");
|
|
require_once VV::root("src/Database/Models/Work/Work.php");
|
|
require_once VV::root("src/Database/Tables/Work/Timeline.php");
|
|
|
|
class Timeline extends Model {
|
|
public function __construct(public readonly string $id) {
|
|
parent::__construct(Endpoints::WORK_TIMELINE, [
|
|
TimelineTable::REF_WORK_ID->value => $this->id
|
|
]);
|
|
}
|
|
|
|
public static function all(array $params = []): array {
|
|
return array_map(fn(array $item): Timeline => new Timeline($item[TimelineTable::REF_WORK_ID->value]), parent::list(Endpoints::WORK_TIMELINE, $params));
|
|
}
|
|
|
|
public function work(): Work {
|
|
return new Work($this->get(TimelineTable::REF_WORK_ID->value));
|
|
}
|
|
|
|
public function year(): int {
|
|
return $this->get(TimelineTable::YEAR->value);
|
|
}
|
|
|
|
public function month(): int {
|
|
return $this->get(TimelineTable::MONTH->value);
|
|
}
|
|
|
|
public function day(): int {
|
|
return $this->get(TimelineTable::DAY->value);
|
|
}
|
|
} |