Add MySQL schema dump for phpMyAdmin

This commit is contained in:
Thomas
2025-10-28 14:08:03 +01:00
parent f956a735ca
commit 8e608d03ec
49 changed files with 1929 additions and 1 deletions

54
app/Models/User.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
namespace App\Models;
class User extends Model
{
protected static string $table = 'users';
public int $id;
public string $role;
public string $name;
public string $email;
public string $pass_hash;
public ?string $phone;
public ?string $address;
public ?int $customer_id;
public bool $is_active;
public ?string $twofa_secret;
public string $created_at;
public string $updated_at;
/**
* @param array<string, mixed> $attributes
*/
protected static function fromArray(array $attributes): static
{
$user = new static();
$user->id = (int) $attributes['id'];
$user->role = (string) $attributes['role'];
$user->name = (string) $attributes['name'];
$user->email = (string) $attributes['email'];
$user->pass_hash = (string) $attributes['pass_hash'];
$user->phone = $attributes['phone'] ?? null;
$user->address = $attributes['address'] ?? null;
$user->customer_id = isset($attributes['customer_id']) ? (int) $attributes['customer_id'] : null;
$user->is_active = (bool) $attributes['is_active'];
$user->twofa_secret = $attributes['twofa_secret'] ?? null;
$user->created_at = (string) $attributes['created_at'];
$user->updated_at = (string) $attributes['updated_at'];
return $user;
}
public static function findByEmail(string $email): ?self
{
$stmt = \App\Core\Database::connection()->prepare('SELECT * FROM users WHERE email = :email LIMIT 1');
$stmt->execute(['email' => $email]);
$row = $stmt->fetch();
if (!$row) {
return null;
}
return self::fromArray($row);
}
}