скрытие магазина
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user