AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

web.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. use App\Http\Controllers\AutomaticDiscountController;
  3. use App\Http\Controllers\BentoSectionController;
  4. use App\Http\Controllers\BillingController;
  5. use App\Http\Controllers\CartController;
  6. use App\Http\Controllers\CheckoutController;
  7. use App\Http\Controllers\CollectionController;
  8. use App\Http\Controllers\DiscountCodeController;
  9. use App\Http\Controllers\FeaturedProductController;
  10. use App\Http\Controllers\HeroImageController;
  11. use App\Http\Controllers\OrderController;
  12. use App\Http\Controllers\ProductController;
  13. use App\Http\Controllers\SectionLayoutController;
  14. use App\Http\Controllers\StoreController;
  15. use App\Http\Controllers\StoreDesignController;
  16. use App\Http\Controllers\StoreGenerationController;
  17. use App\Http\Controllers\StorePublishController;
  18. use App\Http\Controllers\StoreSettingsController;
  19. use App\Http\Controllers\StoreStyleController;
  20. use App\Http\Controllers\StripeWebhookController;
  21. use App\Http\Controllers\VideoSectionController;
  22. use Illuminate\Support\Facades\Route;
  23. /*
  24. |--------------------------------------------------------------------------
  25. | Live stores
  26. |--------------------------------------------------------------------------
  27. |
  28. | A published store has its own address: "<store name>.<domain>", such as
  29. | sambal-nenek.localhost. Shoppers need no login. These routes are listed
  30. | first so that on a store's address nothing else of the app can be opened.
  31. |
  32. */
  33. Route::domain('{storeSlug}.'.config('storefront.domain'))
  34. ->middleware('throttle:240,1')
  35. ->name('storefront.')
  36. ->group(function () {
  37. Route::get('/', [StoreDesignController::class, 'preview'])->name('home');
  38. Route::get('shop', [StoreDesignController::class, 'shop'])->name('shop');
  39. Route::get('products/{productSlug}', [StoreDesignController::class, 'product'])->name('product');
  40. Route::get('collections/{collectionSlug}', [StoreDesignController::class, 'collection'])->name('collection');
  41. Route::get('cart', [CartController::class, 'show'])->name('cart');
  42. Route::post('cart/items', [CartController::class, 'add'])->name('cart.add');
  43. Route::patch('cart/items/{line}', [CartController::class, 'update'])->name('cart.update')->where('line', '[0-9]+(?:-[0-9]+)?');
  44. Route::delete('cart/items/{line}', [CartController::class, 'remove'])->name('cart.remove')->where('line', '[0-9]+(?:-[0-9]+)?');
  45. Route::post('cart/discount', [CartController::class, 'applyDiscount'])->middleware('throttle:20,1')->name('cart.discount');
  46. Route::delete('cart/discount', [CartController::class, 'removeDiscount'])->name('cart.discount.remove');
  47. Route::get('checkout', [CheckoutController::class, 'show'])->name('checkout');
  48. Route::post('checkout', [CheckoutController::class, 'store'])->middleware('throttle:20,1')->name('checkout.store');
  49. Route::get('orders/{publicId}', [CheckoutController::class, 'order'])->name('order');
  50. // Pages the merchant added, such as /about.
  51. Route::get('{pageId}', [StoreDesignController::class, 'page'])->name('page')->where('pageId', '[a-z][a-z0-9-]*');
  52. // Anything else on a store's address does not exist. This hides the dashboard and login pages there.
  53. Route::any('{any}', fn () => abort(404))->where('any', '.*')->name('missing');
  54. });
  55. Route::inertia('/', 'welcome')->name('home');
  56. // Called by Stripe, not by a browser, so it has no login. Each message is checked with a signing secret.
  57. Route::post('stripe/webhook', StripeWebhookController::class)->name('stripe.webhook');
  58. Route::middleware(['auth', 'verified'])->group(function () {
  59. Route::get('dashboard', [StoreController::class, 'index'])->name('dashboard');
  60. Route::get('billing', [BillingController::class, 'index'])->name('billing');
  61. Route::post('billing/subscribe', [BillingController::class, 'subscribe'])->name('billing.subscribe');
  62. Route::post('billing/cancel', [BillingController::class, 'cancel'])->name('billing.cancel');
  63. Route::post('billing/resume', [BillingController::class, 'resume'])->name('billing.resume');
  64. Route::get('stores/create', [StoreController::class, 'create'])->name('stores.create');
  65. Route::post('stores', [StoreController::class, 'store'])->name('stores.store');
  66. Route::get('stores/{slug}', [StoreController::class, 'show'])->name('stores.show');
  67. Route::get('stores/{slug}/preview', [StoreDesignController::class, 'preview'])->name('stores.preview');
  68. Route::get('stores/{slug}/preview/shop', [StoreDesignController::class, 'shop'])->name('stores.preview.shop');
  69. Route::get('stores/{slug}/preview/products/{productSlug}', [StoreDesignController::class, 'product'])->name('stores.preview.product');
  70. Route::get('stores/{slug}/preview/collections/{collectionSlug}', [StoreDesignController::class, 'collection'])->name('stores.preview.collection');
  71. Route::get('stores/{slug}/collections/create', [CollectionController::class, 'create'])->name('stores.collections.create');
  72. Route::post('stores/{slug}/collections', [CollectionController::class, 'store'])->name('stores.collections.store');
  73. Route::get('stores/{slug}/collections/{collection}/edit', [CollectionController::class, 'edit'])->name('stores.collections.edit')->whereNumber('collection');
  74. Route::put('stores/{slug}/collections/{collection}', [CollectionController::class, 'update'])->name('stores.collections.update')->whereNumber('collection');
  75. Route::delete('stores/{slug}/collections/{collection}', [CollectionController::class, 'destroy'])->name('stores.collections.destroy')->whereNumber('collection');
  76. Route::get('stores/{slug}/preview/cart', [CartController::class, 'show'])->name('stores.preview.cart');
  77. Route::post('stores/{slug}/preview/cart/items', [CartController::class, 'add'])->name('stores.preview.cart.add');
  78. Route::patch('stores/{slug}/preview/cart/items/{line}', [CartController::class, 'update'])->name('stores.preview.cart.update')->where('line', '[0-9]+(?:-[0-9]+)?');
  79. Route::delete('stores/{slug}/preview/cart/items/{line}', [CartController::class, 'remove'])->name('stores.preview.cart.remove')->where('line', '[0-9]+(?:-[0-9]+)?');
  80. Route::post('stores/{slug}/preview/cart/discount', [CartController::class, 'applyDiscount'])->name('stores.preview.cart.discount');
  81. Route::delete('stores/{slug}/preview/cart/discount', [CartController::class, 'removeDiscount'])->name('stores.preview.cart.discount.remove');
  82. Route::get('stores/{slug}/preview/checkout', [CheckoutController::class, 'show'])->name('stores.preview.checkout');
  83. Route::post('stores/{slug}/preview/checkout', [CheckoutController::class, 'store'])->name('stores.preview.checkout.store');
  84. Route::get('stores/{slug}/preview/orders/{publicId}', [CheckoutController::class, 'order'])->name('stores.preview.order');
  85. // Pages the merchant added, such as /about. Listed after the store's own pages so those win.
  86. Route::get('stores/{slug}/preview/{pageId}', [StoreDesignController::class, 'page'])->name('stores.preview.page')->where('pageId', '[a-z][a-z0-9-]*');
  87. Route::get('stores/{slug}/discounts', [DiscountCodeController::class, 'index'])->name('stores.discounts.index');
  88. Route::get('stores/{slug}/discounts/create', [DiscountCodeController::class, 'create'])->name('stores.discounts.create');
  89. Route::post('stores/{slug}/discounts', [DiscountCodeController::class, 'store'])->name('stores.discounts.store');
  90. Route::get('stores/{slug}/discounts/{discount}/edit', [DiscountCodeController::class, 'edit'])->name('stores.discounts.edit')->whereNumber('discount');
  91. Route::put('stores/{slug}/discounts/{discount}', [DiscountCodeController::class, 'update'])->name('stores.discounts.update')->whereNumber('discount');
  92. Route::delete('stores/{slug}/discounts/{discount}', [DiscountCodeController::class, 'destroy'])->name('stores.discounts.destroy')->whereNumber('discount');
  93. Route::get('stores/{slug}/automatic-discounts/create', [AutomaticDiscountController::class, 'create'])->name('stores.automatic-discounts.create');
  94. Route::post('stores/{slug}/automatic-discounts', [AutomaticDiscountController::class, 'store'])->name('stores.automatic-discounts.store');
  95. Route::get('stores/{slug}/automatic-discounts/{offer}/edit', [AutomaticDiscountController::class, 'edit'])->name('stores.automatic-discounts.edit')->whereNumber('offer');
  96. Route::put('stores/{slug}/automatic-discounts/{offer}', [AutomaticDiscountController::class, 'update'])->name('stores.automatic-discounts.update')->whereNumber('offer');
  97. Route::delete('stores/{slug}/automatic-discounts/{offer}', [AutomaticDiscountController::class, 'destroy'])->name('stores.automatic-discounts.destroy')->whereNumber('offer');
  98. Route::get('stores/{slug}/orders', [OrderController::class, 'index'])->name('stores.orders.index');
  99. Route::get('stores/{slug}/orders/{order}', [OrderController::class, 'show'])->name('stores.orders.show')->whereNumber('order');
  100. Route::post('stores/{slug}/orders/{order}/ship', [OrderController::class, 'ship'])->name('stores.orders.ship')->whereNumber('order');
  101. Route::get('stores/{slug}/products', [ProductController::class, 'index'])->name('stores.products.index');
  102. Route::get('stores/{slug}/products/create', [ProductController::class, 'create'])->name('stores.products.create');
  103. Route::post('stores/{slug}/products', [ProductController::class, 'store'])->name('stores.products.store');
  104. Route::get('stores/{slug}/products/{product}/edit', [ProductController::class, 'edit'])->name('stores.products.edit')->whereNumber('product');
  105. // Saving uses POST, not PUT, because browsers can only upload files with POST.
  106. Route::post('stores/{slug}/products/{product}', [ProductController::class, 'update'])->name('stores.products.update')->whereNumber('product');
  107. Route::delete('stores/{slug}/products/{product}', [ProductController::class, 'destroy'])->name('stores.products.destroy')->whereNumber('product');
  108. Route::delete('stores/{slug}/products/{product}/images/{image}', [ProductController::class, 'destroyImage'])->name('stores.products.images.destroy')->whereNumber(['product', 'image']);
  109. Route::put('stores/{slug}/featured/{sectionId}', [FeaturedProductController::class, 'update'])->name('stores.featured.update');
  110. Route::put('stores/{slug}/hero/{sectionId}', [HeroImageController::class, 'update'])->name('stores.hero.update');
  111. Route::put('stores/{slug}/style', [StoreStyleController::class, 'update'])->name('stores.style.update');
  112. Route::put('stores/{slug}/layouts/{sectionId}', [SectionLayoutController::class, 'update'])->name('stores.layouts.update');
  113. Route::post('stores/{slug}/videos', [VideoSectionController::class, 'store'])->name('stores.videos.store');
  114. Route::put('stores/{slug}/videos/{sectionId}', [VideoSectionController::class, 'update'])->name('stores.videos.update');
  115. Route::delete('stores/{slug}/videos/{sectionId}', [VideoSectionController::class, 'destroy'])->name('stores.videos.destroy');
  116. Route::post('stores/{slug}/bento', [BentoSectionController::class, 'store'])->name('stores.bento.store');
  117. Route::put('stores/{slug}/bento/{sectionId}', [BentoSectionController::class, 'update'])->name('stores.bento.update');
  118. Route::delete('stores/{slug}/bento/{sectionId}', [BentoSectionController::class, 'destroy'])->name('stores.bento.destroy');
  119. Route::post('stores/{slug}/hero/{sectionId}/photo', [HeroImageController::class, 'upload'])->name('stores.hero.upload');
  120. Route::get('stores/{slug}/settings', [StoreSettingsController::class, 'edit'])->name('stores.settings');
  121. Route::put('stores/{slug}/settings', [StoreSettingsController::class, 'update'])->name('stores.settings.update');
  122. Route::post('stores/{slug}/publish', [StorePublishController::class, 'publish'])->name('stores.publish');
  123. Route::post('stores/{slug}/unpublish', [StorePublishController::class, 'unpublish'])->name('stores.unpublish');
  124. Route::post('stores/{slug}/generate', [StoreGenerationController::class, 'generate'])->name('stores.generate');
  125. Route::post('stores/{slug}/edits', [StoreGenerationController::class, 'edit'])->name('stores.edits');
  126. Route::post('stores/{slug}/edits/{generation}/confirm', [StoreGenerationController::class, 'confirm'])->name('stores.edits.confirm')->whereNumber('generation');
  127. Route::post('stores/{slug}/edits/{generation}/cancel', [StoreGenerationController::class, 'cancel'])->name('stores.edits.cancel')->whereNumber('generation');
  128. });
  129. require __DIR__.'/settings.php';