2026-10-09 09:07:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use App\Core\Model;
|
|
|
|
|
|
|
|
|
|
class User extends Model
|
|
|
|
|
{
|
|
|
|
|
protected static string $table = 'users';
|
|
|
|
|
|
|
|
|
|
public static function byEmail(string $email): ?static
|
|
|
|
|
{
|
|
|
|
|
$row = db()->fetchOne('SELECT * FROM `users` WHERE email = ?', [$email]);
|
|
|
|
|
|
|
|
|
|
return $row === null ? null : static::fromRow($row);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-08 17:24:41 +01:00
|
|
|
/** Admins und Mitglieder, die als Tour Guide wählbar sind. */
|
2026-11-08 17:13:11 +01:00
|
|
|
public static function selectableGuides(): array
|
|
|
|
|
{
|
|
|
|
|
$rows = db()->fetchAll(
|
|
|
|
|
'SELECT * FROM `users` WHERE role IN (?, ?) ORDER BY name',
|
|
|
|
|
['ADMIN', 'MEMBER']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return array_map(fn(array $row) => static::fromRow($row), $rows);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-09 09:07:18 +02:00
|
|
|
public function isAdmin(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->role === 'ADMIN';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isMember(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->role === 'MEMBER';
|
|
|
|
|
}
|
|
|
|
|
}
|