Rolle TOUR GUIDE einführen
This commit is contained in:
parent
4f65250190
commit
ca3c490d4a
11 changed files with 54 additions and 10 deletions
|
|
@ -41,12 +41,12 @@ class User extends Model
|
|||
return trim(preg_replace('/\s+/u', ' ', $name) ?? '');
|
||||
}
|
||||
|
||||
/** Admins und Mitglieder, die als Tour Guide wählbar sind. */
|
||||
/** Admins und Tour Guides, die als Tour Guide wählbar sind. */
|
||||
public static function selectableGuides(): array
|
||||
{
|
||||
$rows = db()->fetchAll(
|
||||
'SELECT * FROM `users` WHERE role IN (?, ?) ORDER BY name',
|
||||
['ADMIN', 'MEMBER']
|
||||
['ADMIN', 'TOUR GUIDE']
|
||||
);
|
||||
|
||||
return array_map(fn(array $row) => static::fromRow($row), $rows);
|
||||
|
|
@ -57,8 +57,19 @@ class User extends Model
|
|||
return $this->role === 'ADMIN';
|
||||
}
|
||||
|
||||
public function isTourGuide(): bool
|
||||
{
|
||||
return $this->role === 'TOUR GUIDE';
|
||||
}
|
||||
|
||||
public function isMember(): bool
|
||||
{
|
||||
return $this->role === 'MEMBER';
|
||||
return in_array($this->role, ['MEMBER', 'TOUR GUIDE'], true);
|
||||
}
|
||||
|
||||
/** Darf Touren anlegen (Admin oder Tour Guide). */
|
||||
public function canCreateTours(): bool
|
||||
{
|
||||
return $this->isAdmin() || $this->isTourGuide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue