Fix LESS import error and refactor project structure
This commit is contained in:
@@ -6,9 +6,6 @@ use App\Core\Controller;
|
||||
use App\Models\Cart;
|
||||
use App\Models\Product;
|
||||
|
||||
/**
|
||||
* CartController - контроллер корзины
|
||||
*/
|
||||
class CartController extends Controller
|
||||
{
|
||||
private Cart $cartModel;
|
||||
@@ -20,9 +17,6 @@ class CartController extends Controller
|
||||
$this->productModel = new Product();
|
||||
}
|
||||
|
||||
/**
|
||||
* Страница корзины
|
||||
*/
|
||||
public function index(): void
|
||||
{
|
||||
$this->requireAuth();
|
||||
@@ -39,9 +33,6 @@ class CartController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавить товар в корзину
|
||||
*/
|
||||
public function add(): void
|
||||
{
|
||||
if (!$this->isAuthenticated()) {
|
||||
@@ -64,7 +55,6 @@ class CartController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем наличие товара
|
||||
$product = $this->productModel->find($productId);
|
||||
|
||||
if (!$product || !$product['is_available']) {
|
||||
@@ -75,7 +65,6 @@ class CartController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем количество на складе
|
||||
$cartItem = $this->cartModel->getItem($userId, $productId);
|
||||
$currentQty = $cartItem ? $cartItem['quantity'] : 0;
|
||||
$newQty = $currentQty + $quantity;
|
||||
@@ -88,7 +77,6 @@ class CartController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
// Добавляем в корзину
|
||||
$result = $this->cartModel->addItem($userId, $productId, $quantity);
|
||||
|
||||
if ($result) {
|
||||
@@ -106,9 +94,6 @@ class CartController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновить количество товара
|
||||
*/
|
||||
public function update(): void
|
||||
{
|
||||
if (!$this->isAuthenticated()) {
|
||||
@@ -124,7 +109,6 @@ class CartController extends Controller
|
||||
$userId = $this->getCurrentUser()['id'];
|
||||
|
||||
if ($quantity <= 0) {
|
||||
// Если количество 0 или меньше - удаляем
|
||||
$this->cartModel->removeItem($userId, $productId);
|
||||
$cartCount = $this->cartModel->getCount($userId);
|
||||
$this->json([
|
||||
@@ -134,7 +118,6 @@ class CartController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем наличие на складе
|
||||
$product = $this->productModel->find($productId);
|
||||
if (!$product || $quantity > $product['stock_quantity']) {
|
||||
$this->json([
|
||||
@@ -161,9 +144,6 @@ class CartController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Удалить товар из корзины
|
||||
*/
|
||||
public function remove(): void
|
||||
{
|
||||
if (!$this->isAuthenticated()) {
|
||||
@@ -193,9 +173,6 @@ class CartController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить количество товаров в корзине
|
||||
*/
|
||||
public function count(): void
|
||||
{
|
||||
if (!$this->isAuthenticated()) {
|
||||
@@ -215,4 +192,3 @@ class CartController extends Controller
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user