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

@@ -8,9 +8,6 @@ use App\Models\Category;
use App\Models\Order;
use App\Models\User;
/**
* AdminController - контроллер админ-панели
*/
class AdminController extends Controller
{
private Product $productModel;
@@ -26,9 +23,6 @@ class AdminController extends Controller
$this->userModel = new User();
}
/**
* Дашборд
*/
public function dashboard(): void
{
$this->requireAdmin();
@@ -47,11 +41,6 @@ class AdminController extends Controller
], 'admin');
}
// ========== Товары ==========
/**
* Список товаров
*/
public function products(): void
{
$this->requireAdmin();
@@ -68,9 +57,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Форма добавления товара
*/
public function addProduct(): void
{
$this->requireAdmin();
@@ -85,9 +71,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Сохранение нового товара
*/
public function storeProduct(): void
{
$this->requireAdmin();
@@ -116,9 +99,6 @@ class AdminController extends Controller
}
}
/**
* Форма редактирования товара
*/
public function editProduct(int $id): void
{
$this->requireAdmin();
@@ -140,9 +120,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Обновление товара
*/
public function updateProduct(int $id): void
{
$this->requireAdmin();
@@ -168,9 +145,6 @@ class AdminController extends Controller
}
}
/**
* Удаление товара (делаем недоступным)
*/
public function deleteProduct(int $id): void
{
$this->requireAdmin();
@@ -179,11 +153,6 @@ class AdminController extends Controller
$this->redirect('/admin/products?message=' . urlencode('Товар скрыт'));
}
// ========== Категории ==========
/**
* Список категорий
*/
public function categories(): void
{
$this->requireAdmin();
@@ -198,9 +167,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Форма добавления категории
*/
public function addCategory(): void
{
$this->requireAdmin();
@@ -215,9 +181,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Сохранение категории
*/
public function storeCategory(): void
{
$this->requireAdmin();
@@ -238,9 +201,6 @@ class AdminController extends Controller
}
}
/**
* Форма редактирования категории
*/
public function editCategory(int $id): void
{
$this->requireAdmin();
@@ -262,9 +222,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Обновление категории
*/
public function updateCategory(int $id): void
{
$this->requireAdmin();
@@ -285,9 +242,6 @@ class AdminController extends Controller
}
}
/**
* Удаление категории
*/
public function deleteCategory(int $id): void
{
$this->requireAdmin();
@@ -304,11 +258,6 @@ class AdminController extends Controller
}
}
// ========== Заказы ==========
/**
* Список заказов
*/
public function orders(): void
{
$this->requireAdmin();
@@ -321,9 +270,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Детали заказа
*/
public function orderDetails(int $id): void
{
$this->requireAdmin();
@@ -341,9 +287,6 @@ class AdminController extends Controller
], 'admin');
}
/**
* Обновление статуса заказа
*/
public function updateOrderStatus(int $id): void
{
$this->requireAdmin();
@@ -354,11 +297,6 @@ class AdminController extends Controller
$this->redirect('/admin/orders/' . $id);
}
// ========== Пользователи ==========
/**
* Список пользователей
*/
public function users(): void
{
$this->requireAdmin();
@@ -371,4 +309,3 @@ class AdminController extends Controller
], 'admin');
}
}

View File

@@ -5,9 +5,6 @@ namespace App\Controllers;
use App\Core\Controller;
use App\Models\User;
/**
* AuthController - контроллер авторизации
*/
class AuthController extends Controller
{
private User $userModel;
@@ -17,9 +14,6 @@ class AuthController extends Controller
$this->userModel = new User();
}
/**
* Форма входа
*/
public function loginForm(): void
{
if ($this->isAuthenticated()) {
@@ -35,9 +29,6 @@ class AuthController extends Controller
]);
}
/**
* Обработка входа
*/
public function login(): void
{
$email = $this->getPost('email', '');
@@ -62,7 +53,6 @@ class AuthController extends Controller
return;
}
// Устанавливаем сессию
$this->setSession($user);
$this->json([
@@ -71,9 +61,6 @@ class AuthController extends Controller
]);
}
/**
* Форма регистрации
*/
public function registerForm(): void
{
if ($this->isAuthenticated()) {
@@ -86,15 +73,11 @@ class AuthController extends Controller
'success' => $_SESSION['registration_success'] ?? null
]);
// Очищаем flash данные
unset($_SESSION['registration_errors']);
unset($_SESSION['old_data']);
unset($_SESSION['registration_success']);
}
/**
* Обработка регистрации
*/
public function register(): void
{
$errors = [];
@@ -107,7 +90,6 @@ class AuthController extends Controller
$confirmPassword = $this->getPost('confirm-password', '');
$privacy = $this->getPost('privacy');
// Валидация
if (empty($fullName) || strlen($fullName) < 3) {
$errors[] = 'ФИО должно содержать минимум 3 символа';
}
@@ -136,7 +118,6 @@ class AuthController extends Controller
$errors[] = 'Необходимо согласие с условиями обработки персональных данных';
}
// Проверяем существование email
if (empty($errors) && $this->userModel->emailExists($email)) {
$errors[] = 'Пользователь с таким email уже существует';
}
@@ -153,7 +134,6 @@ class AuthController extends Controller
return;
}
// Создаем пользователя
try {
$userId = $this->userModel->register([
'email' => $email,
@@ -167,10 +147,7 @@ class AuthController extends Controller
throw new \Exception('Ошибка при создании пользователя');
}
// Получаем созданного пользователя
$user = $this->userModel->find($userId);
// Устанавливаем сессию
$this->setSession($user);
$_SESSION['registration_success'] = 'Регистрация прошла успешно!';
@@ -188,9 +165,6 @@ class AuthController extends Controller
}
}
/**
* Выход из системы
*/
public function logout(): void
{
session_destroy();
@@ -199,9 +173,6 @@ class AuthController extends Controller
$this->redirect('/');
}
/**
* Установить сессию пользователя
*/
private function setSession(array $user): void
{
$_SESSION['user_id'] = $user['user_id'];
@@ -214,4 +185,3 @@ class AuthController extends Controller
$_SESSION['login_time'] = time();
}
}

View File

@@ -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
]);
}
}

View File

@@ -4,14 +4,8 @@ namespace App\Controllers;
use App\Core\Controller;
/**
* HomeController - контроллер главной страницы
*/
class HomeController extends Controller
{
/**
* Главная страница
*/
public function index(): void
{
$user = $this->getCurrentUser();
@@ -23,4 +17,3 @@ class HomeController extends Controller
]);
}
}

View File

@@ -6,9 +6,6 @@ use App\Core\Controller;
use App\Models\Order;
use App\Models\Cart;
/**
* OrderController - контроллер заказов
*/
class OrderController extends Controller
{
private Order $orderModel;
@@ -20,9 +17,6 @@ class OrderController extends Controller
$this->cartModel = new Cart();
}
/**
* Страница оформления заказа (корзина)
*/
public function checkout(): void
{
$this->requireAuth();
@@ -39,9 +33,6 @@ class OrderController extends Controller
]);
}
/**
* Создание заказа
*/
public function create(): void
{
if (!$this->isAuthenticated()) {
@@ -63,7 +54,6 @@ class OrderController extends Controller
return;
}
// Получаем данные заказа
$orderData = [
'customer_name' => $this->getPost('full_name', $user['full_name']),
'customer_email' => $this->getPost('email', $user['email']),
@@ -79,7 +69,6 @@ class OrderController extends Controller
'notes' => $this->getPost('notes', '')
];
// Валидация
if (empty($orderData['customer_name'])) {
$this->json([
'success' => false,
@@ -122,4 +111,3 @@ class OrderController extends Controller
}
}
}

View File

@@ -4,14 +4,8 @@ namespace App\Controllers;
use App\Core\Controller;
/**
* PageController - контроллер статических страниц
*/
class PageController extends Controller
{
/**
* Страница услуг
*/
public function services(): void
{
$this->view('pages/services', [
@@ -20,9 +14,6 @@ class PageController extends Controller
]);
}
/**
* Страница доставки и оплаты
*/
public function delivery(): void
{
$this->view('pages/delivery', [
@@ -31,9 +22,6 @@ class PageController extends Controller
]);
}
/**
* Страница гарантии
*/
public function warranty(): void
{
$this->view('pages/warranty', [
@@ -42,4 +30,3 @@ class PageController extends Controller
]);
}
}

View File

@@ -6,9 +6,6 @@ use App\Core\Controller;
use App\Models\Product;
use App\Models\Category;
/**
* ProductController - контроллер товаров и каталога
*/
class ProductController extends Controller
{
private Product $productModel;
@@ -20,9 +17,6 @@ class ProductController extends Controller
$this->categoryModel = new Category();
}
/**
* Каталог товаров
*/
public function catalog(): void
{
$this->requireAuth();
@@ -30,7 +24,6 @@ class ProductController extends Controller
$user = $this->getCurrentUser();
$isAdmin = $this->isAdmin();
// Получаем параметры фильтрации
$filters = [
'category_id' => (int) $this->getQuery('category', 0),
'search' => $this->getQuery('search', ''),
@@ -42,7 +35,6 @@ class ProductController extends Controller
$showAll = $isAdmin && $this->getQuery('show_all') === '1';
// Получаем данные
$categories = $this->categoryModel->getActive();
$products = $showAll
? $this->productModel->getAllForAdmin(true)
@@ -51,7 +43,6 @@ class ProductController extends Controller
$availableColors = $this->productModel->getAvailableColors();
$availableMaterials = $this->productModel->getAvailableMaterials();
// Подкатегории для выбранной категории
$subcategories = [];
if ($filters['category_id'] > 0) {
$subcategories = $this->categoryModel->getChildren($filters['category_id']);
@@ -72,9 +63,6 @@ class ProductController extends Controller
]);
}
/**
* Страница товара
*/
public function show(int $id): void
{
$this->requireAuth();
@@ -99,4 +87,3 @@ class ProductController extends Controller
]);
}
}