This commit is contained in:
Lars Behrends
2025-10-18 22:03:30 +02:00
parent f4c1cfc164
commit ca2d3a6960
45 changed files with 4827 additions and 326 deletions

View File

@@ -11,10 +11,37 @@ abstract class Model
protected array $fillable = [];
protected array $hidden = [];
protected array $casts = [];
protected array $attributes = [];
public function __construct(\PDO $pdo)
public function __construct(\PDO $pdo, array $data = [])
{
$this->pdo = $pdo;
$this->attributes = $data;
}
public function __get(string $key)
{
return $this->attributes[$key] ?? null;
}
public function __set(string $key, $value)
{
$this->attributes[$key] = $value;
}
public function __isset(string $key): bool
{
return isset($this->attributes[$key]);
}
public function getAttributes(): array
{
return $this->attributes;
}
public function setAttributes(array $data)
{
$this->attributes = $data;
}
public function find(int $id): ?array