Updated the proostekrant to work properly again.
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
class User {
|
||||
private static $table = 'users';
|
||||
|
||||
public static function all() {
|
||||
$db = Database::getInstance();
|
||||
return $db->fetchAll("SELECT * FROM " . self::$table . " WHERE is_active = 1 ORDER BY display_name");
|
||||
}
|
||||
|
||||
public static function find($id) {
|
||||
$db = Database::getInstance();
|
||||
return $db->fetch("SELECT * FROM " . self::$table . " WHERE id = ?", [$id]);
|
||||
}
|
||||
|
||||
public static function findByUsername($username) {
|
||||
$db = Database::getInstance();
|
||||
return $db->fetch("SELECT * FROM " . self::$table . " WHERE username = ? AND is_active = 1", [$username]);
|
||||
}
|
||||
|
||||
public static function getByIds($ids) {
|
||||
if (empty($ids)) return [];
|
||||
|
||||
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
||||
$db = Database::getInstance();
|
||||
return $db->fetchAll("SELECT * FROM " . self::$table . " WHERE id IN ({$placeholders}) AND is_active = 1", $ids);
|
||||
}
|
||||
|
||||
public static function updateProfileImage($userId, $imagePath) {
|
||||
$db = Database::getInstance();
|
||||
return $db->update(self::$table, ['profile_image' => $imagePath], ['id' => $userId]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user