Initial commit of the Asset Management System, including project structure, Docker configuration, database migrations, and core application files. Added user authentication, asset management features, and basic UI components.
This commit is contained in:
45
app/Models/PasswordReset.php
Normal file
45
app/Models/PasswordReset.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Core\Database;
|
||||
|
||||
class PasswordReset
|
||||
{
|
||||
private Database $database;
|
||||
|
||||
public function __construct(Database $database)
|
||||
{
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
public function create(array $data): int
|
||||
{
|
||||
return $this->database->insert('password_resets', $data);
|
||||
}
|
||||
|
||||
public function findByToken(string $token): ?array
|
||||
{
|
||||
return $this->database->fetch(
|
||||
"SELECT * FROM password_resets WHERE token = :token",
|
||||
['token' => $token]
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
return $this->database->delete('password_resets', 'id = :id', ['id' => $id]) > 0;
|
||||
}
|
||||
|
||||
public function deleteExpired(): int
|
||||
{
|
||||
return $this->database->query(
|
||||
"DELETE FROM password_resets WHERE expires_at < NOW()"
|
||||
)->rowCount();
|
||||
}
|
||||
|
||||
public function deleteByUserId(int $userId): int
|
||||
{
|
||||
return $this->database->delete('password_resets', 'user_id = :user_id', ['user_id' => $userId]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user