AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

SectionLayoutController.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\StorePlan\PlanSchema;
  4. use App\StorePlan\PlanValidator;
  5. use App\StorePlan\SectionLayouts;
  6. use Illuminate\Http\RedirectResponse;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Validation\Rule;
  9. use Inertia\Inertia;
  10. /**
  11. * Changes one section's layout from the Design tab's Layouts box.
  12. * This changes the working design, so a live store shows it after "Publish changes".
  13. */
  14. class SectionLayoutController extends Controller
  15. {
  16. public function update(Request $request, PlanValidator $validator, string $slug, string $sectionId): RedirectResponse
  17. {
  18. $store = $request->user()->stores()->where('slug', $slug)->firstOrFail();
  19. abort_if($store->plan === null, 404);
  20. $type = SectionLayouts::typeOf($store->plan, $sectionId);
  21. abort_if($type === null, 404);
  22. $validated = $request->validate([
  23. 'variant' => ['required', Rule::in(PlanSchema::SECTIONS[$type])],
  24. ]);
  25. $store->plan = $validator->validate(SectionLayouts::update($store->plan, $sectionId, $validated['variant']));
  26. $store->save();
  27. Inertia::flash('toast', ['type' => 'success', 'message' => $store->isPublished()
  28. ? __('Saved. Click "Publish changes" to show it on your live store.')
  29. : __('Layout saved.')]);
  30. return to_route('stores.show', $store->slug);
  31. }
  32. }