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ů.

StoreDesignController.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Controllers\Concerns\RendersStorefront;
  4. use App\StorePlan\PlanSchema;
  5. use Illuminate\Http\RedirectResponse;
  6. use Illuminate\Http\Request;
  7. use Inertia\Response;
  8. /**
  9. * The storefront pages: home, shop and product.
  10. */
  11. class StoreDesignController extends Controller
  12. {
  13. use RendersStorefront;
  14. /**
  15. * The home page of the storefront, drawn from the store's saved plan.
  16. */
  17. public function preview(Request $request, string $slug): Response
  18. {
  19. return $this->renderStorefront($request, $this->ownedStore($request, $slug), [
  20. 'type' => 'page',
  21. 'pageId' => PlanSchema::HOME_PAGE,
  22. ]);
  23. }
  24. /**
  25. * Any other page of the plan, such as "about". Its id is its address.
  26. */
  27. public function page(Request $request, string $slug, string $pageId): Response|RedirectResponse
  28. {
  29. $store = $this->ownedStore($request, $slug);
  30. if ($pageId === PlanSchema::HOME_PAGE) {
  31. return to_route('stores.preview', $store->slug);
  32. }
  33. abort_unless(in_array($pageId, array_column($store->plan['pages'] ?? [], 'id'), true), 404);
  34. return $this->renderStorefront($request, $store, ['type' => 'page', 'pageId' => $pageId]);
  35. }
  36. /**
  37. * The shop page: every product shoppers may see.
  38. */
  39. public function shop(Request $request, string $slug): Response
  40. {
  41. return $this->renderStorefront($request, $this->ownedStore($request, $slug), ['type' => 'shop']);
  42. }
  43. /**
  44. * One product's own page.
  45. */
  46. public function product(Request $request, string $slug, string $productSlug): Response
  47. {
  48. $store = $this->ownedStore($request, $slug);
  49. $product = $store->products()->active()->with('images')->where('slug', $productSlug)->firstOrFail();
  50. return $this->renderStorefront($request, $store, ['type' => 'product', 'product' => $product->toStorefront()]);
  51. }
  52. }