...
This commit is contained in:
parent
1db373a03d
commit
9bcbd3e194
118 changed files with 1116 additions and 155 deletions
29
motorradig/src/Models/User.php
Normal file
29
motorradig/src/Models/User.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?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';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue