Fix LESS import error and refactor project structure

This commit is contained in:
kirill.khorkov
2026-01-03 18:59:56 +03:00
parent 1bb0fc02e6
commit 4a8d4f8c3f
201 changed files with 891 additions and 14311 deletions

View File

@@ -4,17 +4,11 @@ namespace App\Models;
use App\Core\Model;
/**
* Cart - модель корзины
*/
class Cart extends Model
{
protected string $table = 'cart';
protected string $primaryKey = 'cart_id';
/**
* Получить корзину пользователя
*/
public function getUserCart(int $userId): array
{
$sql = "SELECT
@@ -33,9 +27,6 @@ class Cart extends Model
return $this->query($sql, [$userId]);
}
/**
* Получить общую сумму корзины
*/
public function getCartTotal(int $userId): array
{
$sql = "SELECT
@@ -52,9 +43,6 @@ class Cart extends Model
];
}
/**
* Получить количество товаров в корзине
*/
public function getCount(int $userId): int
{
$sql = "SELECT COALESCE(SUM(quantity), 0) as total FROM {$this->table} WHERE user_id = ?";
@@ -62,19 +50,14 @@ class Cart extends Model
return (int) $result['total'];
}
/**
* Добавить товар в корзину
*/
public function addItem(int $userId, int $productId, int $quantity = 1): bool
{
// Проверяем, есть ли уже этот товар в корзине
$existing = $this->findWhere([
'user_id' => $userId,
'product_id' => $productId
]);
if ($existing) {
// Увеличиваем количество
$newQuantity = $existing['quantity'] + $quantity;
return $this->update($existing['cart_id'], [
'quantity' => $newQuantity,
@@ -82,7 +65,6 @@ class Cart extends Model
]);
}
// Добавляем новую запись
return $this->create([
'user_id' => $userId,
'product_id' => $productId,
@@ -90,9 +72,6 @@ class Cart extends Model
]) !== null;
}
/**
* Обновить количество товара в корзине
*/
public function updateQuantity(int $userId, int $productId, int $quantity): bool
{
$sql = "UPDATE {$this->table}
@@ -101,27 +80,18 @@ class Cart extends Model
return $this->execute($sql, [$quantity, $userId, $productId]);
}
/**
* Удалить товар из корзины
*/
public function removeItem(int $userId, int $productId): bool
{
$sql = "DELETE FROM {$this->table} WHERE user_id = ? AND product_id = ?";
return $this->execute($sql, [$userId, $productId]);
}
/**
* Очистить корзину пользователя
*/
public function clearCart(int $userId): bool
{
$sql = "DELETE FROM {$this->table} WHERE user_id = ?";
return $this->execute($sql, [$userId]);
}
/**
* Проверить, есть ли товар в корзине
*/
public function hasItem(int $userId, int $productId): bool
{
$item = $this->findWhere([
@@ -131,9 +101,6 @@ class Cart extends Model
return $item !== null;
}
/**
* Получить товар из корзины
*/
public function getItem(int $userId, int $productId): ?array
{
return $this->findWhere([
@@ -142,4 +109,3 @@ class Cart extends Model
]);
}
}