скрытие магазина

This commit is contained in:
2026-07-28 14:47:07 +04:00
parent 373649c3d2
commit 66251ede8e
15 changed files with 169 additions and 172 deletions
+22 -1
View File
@@ -9,6 +9,7 @@ use App\Http\Requests\Admin\SaveShopProductRequest;
use App\Models\ShopCategory;
use App\Models\ShopProduct;
use App\Services\ShopCatalogService;
use App\Services\StoreAvailabilityService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
@@ -18,7 +19,11 @@ class ShopController extends Controller
{
use BuildsPortalProps;
public function index(Request $request, ShopCatalogService $catalog): Response
public function index(
Request $request,
ShopCatalogService $catalog,
StoreAvailabilityService $availability,
): Response
{
$categories = $catalog->categories();
@@ -68,6 +73,8 @@ class ShopController extends Controller
->all(),
'categoryStoreUrl' => route('admin.shop.categories.store'),
'productStoreUrl' => route('admin.shop.products.store'),
'shopEnabled' => $availability->isEnabled(),
'availabilityUpdateUrl' => route('admin.shop.availability.update'),
'productTypes' => collect([
1 => 'Предмет',
3 => 'Маунт',
@@ -80,6 +87,20 @@ class ShopController extends Controller
]);
}
public function updateAvailability(Request $request, StoreAvailabilityService $availability): RedirectResponse
{
$validated = $request->validate([
'enabled' => ['required', 'boolean'],
]);
$enabled = (bool) $validated['enabled'];
$availability->setEnabled($enabled);
return back()->with('status', $enabled
? 'Магазин и пополнение включены.'
: 'Магазин и пополнение выключены.');
}
public function storeCategory(SaveShopCategoryRequest $request, ShopCatalogService $catalog): RedirectResponse
{
$catalog->createCategory($request->validated());