донат шоп, управление магазином, яндекс метрика

This commit is contained in:
2026-07-19 19:17:29 +04:00
parent 8bf1b852f0
commit df7f98fe8b
48 changed files with 1859 additions and 18 deletions
@@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\SaveShopCategoryRequest;
use App\Http\Requests\Admin\SaveShopProductRequest;
use App\Models\ShopCategory;
use App\Models\ShopProduct;
use App\Services\ShopCatalogService;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
class ShopController extends Controller
{
public function index(ShopCatalogService $catalog): View
{
return view('admin.shop.index', [
'categories' => $catalog->categories(),
'products' => $catalog->products(),
]);
}
public function storeCategory(SaveShopCategoryRequest $request, ShopCatalogService $catalog): RedirectResponse
{
$catalog->createCategory($request->validated());
return back()->with('status', 'Категория создана.');
}
public function updateCategory(ShopCategory $category, SaveShopCategoryRequest $request, ShopCatalogService $catalog): RedirectResponse
{
$catalog->updateCategory($category, $request->validated());
return back()->with('status', 'Категория обновлена.');
}
public function destroyCategory(ShopCategory $category, ShopCatalogService $catalog): RedirectResponse
{
$catalog->deleteCategory($category);
return back()->with('status', 'Категория удалена.');
}
public function storeProduct(SaveShopProductRequest $request, ShopCatalogService $catalog): RedirectResponse
{
$catalog->createProduct($request->validated());
return back()->with('status', 'Товар создан.');
}
public function updateProduct(ShopProduct $product, SaveShopProductRequest $request, ShopCatalogService $catalog): RedirectResponse
{
$catalog->updateProduct($product, $request->validated());
return back()->with('status', 'Товар обновлён.');
}
public function destroyProduct(ShopProduct $product, ShopCatalogService $catalog): RedirectResponse
{
$catalog->deleteProduct($product);
return back()->with('status', 'Товар удалён.');
}
}