30 lines
548 B
PHP
30 lines
548 B
PHP
|
|
<?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);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isAdmin(): bool
|
||
|
|
{
|
||
|
|
return $this->role === 'ADMIN';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isMember(): bool
|
||
|
|
{
|
||
|
|
return $this->role === 'MEMBER';
|
||
|
|
}
|
||
|
|
}
|