AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

web.php 6.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. use App\Http\Controllers\BillingController;
  3. use App\Http\Controllers\CartController;
  4. use App\Http\Controllers\CheckoutController;
  5. use App\Http\Controllers\OrderController;
  6. use App\Http\Controllers\ProductController;
  7. use App\Http\Controllers\StoreController;
  8. use App\Http\Controllers\StoreDesignController;
  9. use App\Http\Controllers\StoreGenerationController;
  10. use App\Http\Controllers\StorePublishController;
  11. use App\Http\Controllers\StripeWebhookController;
  12. use Illuminate\Support\Facades\Route;
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Live stores
  16. |--------------------------------------------------------------------------
  17. |
  18. | A published store has its own address: "<store name>.<domain>", such as
  19. | sambal-nenek.localhost. Shoppers need no login. These routes are listed
  20. | first so that on a store's address nothing else of the app can be opened.
  21. |
  22. */
  23. Route::domain('{storeSlug}.'.config('storefront.domain'))
  24. ->middleware('throttle:240,1')
  25. ->name('storefront.')
  26. ->group(function () {
  27. Route::get('/', [StoreDesignController::class, 'preview'])->name('home');
  28. Route::get('shop', [StoreDesignController::class, 'shop'])->name('shop');
  29. Route::get('products/{productSlug}', [StoreDesignController::class, 'product'])->name('product');
  30. Route::get('cart', [CartController::class, 'show'])->name('cart');
  31. Route::post('cart/items', [CartController::class, 'add'])->name('cart.add');
  32. Route::patch('cart/items/{product}', [CartController::class, 'update'])->name('cart.update')->whereNumber('product');
  33. Route::delete('cart/items/{product}', [CartController::class, 'remove'])->name('cart.remove')->whereNumber('product');
  34. Route::get('checkout', [CheckoutController::class, 'show'])->name('checkout');
  35. Route::post('checkout', [CheckoutController::class, 'store'])->middleware('throttle:20,1')->name('checkout.store');
  36. Route::get('orders/{publicId}', [CheckoutController::class, 'order'])->name('order');
  37. // Pages the merchant added, such as /about.
  38. Route::get('{pageId}', [StoreDesignController::class, 'page'])->name('page')->where('pageId', '[a-z][a-z0-9-]*');
  39. // Anything else on a store's address does not exist. This hides the dashboard and login pages there.
  40. Route::any('{any}', fn () => abort(404))->where('any', '.*')->name('missing');
  41. });
  42. Route::inertia('/', 'welcome')->name('home');
  43. // Called by Stripe, not by a browser, so it has no login. Each message is checked with a signing secret.
  44. Route::post('stripe/webhook', StripeWebhookController::class)->name('stripe.webhook');
  45. Route::middleware(['auth', 'verified'])->group(function () {
  46. Route::get('dashboard', [StoreController::class, 'index'])->name('dashboard');
  47. Route::get('billing', [BillingController::class, 'index'])->name('billing');
  48. Route::post('billing/subscribe', [BillingController::class, 'subscribe'])->name('billing.subscribe');
  49. Route::post('billing/cancel', [BillingController::class, 'cancel'])->name('billing.cancel');
  50. Route::post('billing/resume', [BillingController::class, 'resume'])->name('billing.resume');
  51. Route::get('stores/create', [StoreController::class, 'create'])->name('stores.create');
  52. Route::post('stores', [StoreController::class, 'store'])->name('stores.store');
  53. Route::get('stores/{slug}', [StoreController::class, 'show'])->name('stores.show');
  54. Route::get('stores/{slug}/preview', [StoreDesignController::class, 'preview'])->name('stores.preview');
  55. Route::get('stores/{slug}/preview/shop', [StoreDesignController::class, 'shop'])->name('stores.preview.shop');
  56. Route::get('stores/{slug}/preview/products/{productSlug}', [StoreDesignController::class, 'product'])->name('stores.preview.product');
  57. Route::get('stores/{slug}/preview/cart', [CartController::class, 'show'])->name('stores.preview.cart');
  58. Route::post('stores/{slug}/preview/cart/items', [CartController::class, 'add'])->name('stores.preview.cart.add');
  59. Route::patch('stores/{slug}/preview/cart/items/{product}', [CartController::class, 'update'])->name('stores.preview.cart.update')->whereNumber('product');
  60. Route::delete('stores/{slug}/preview/cart/items/{product}', [CartController::class, 'remove'])->name('stores.preview.cart.remove')->whereNumber('product');
  61. Route::get('stores/{slug}/preview/checkout', [CheckoutController::class, 'show'])->name('stores.preview.checkout');
  62. Route::post('stores/{slug}/preview/checkout', [CheckoutController::class, 'store'])->name('stores.preview.checkout.store');
  63. Route::get('stores/{slug}/preview/orders/{publicId}', [CheckoutController::class, 'order'])->name('stores.preview.order');
  64. // Pages the merchant added, such as /about. Listed after the store's own pages so those win.
  65. Route::get('stores/{slug}/preview/{pageId}', [StoreDesignController::class, 'page'])->name('stores.preview.page')->where('pageId', '[a-z][a-z0-9-]*');
  66. Route::get('stores/{slug}/orders', [OrderController::class, 'index'])->name('stores.orders.index');
  67. Route::get('stores/{slug}/orders/{order}', [OrderController::class, 'show'])->name('stores.orders.show')->whereNumber('order');
  68. Route::get('stores/{slug}/products', [ProductController::class, 'index'])->name('stores.products.index');
  69. Route::get('stores/{slug}/products/create', [ProductController::class, 'create'])->name('stores.products.create');
  70. Route::post('stores/{slug}/products', [ProductController::class, 'store'])->name('stores.products.store');
  71. Route::get('stores/{slug}/products/{product}/edit', [ProductController::class, 'edit'])->name('stores.products.edit')->whereNumber('product');
  72. // Saving uses POST, not PUT, because browsers can only upload files with POST.
  73. Route::post('stores/{slug}/products/{product}', [ProductController::class, 'update'])->name('stores.products.update')->whereNumber('product');
  74. Route::delete('stores/{slug}/products/{product}', [ProductController::class, 'destroy'])->name('stores.products.destroy')->whereNumber('product');
  75. Route::delete('stores/{slug}/products/{product}/images/{image}', [ProductController::class, 'destroyImage'])->name('stores.products.images.destroy')->whereNumber(['product', 'image']);
  76. Route::post('stores/{slug}/publish', [StorePublishController::class, 'publish'])->name('stores.publish');
  77. Route::post('stores/{slug}/unpublish', [StorePublishController::class, 'unpublish'])->name('stores.unpublish');
  78. Route::post('stores/{slug}/generate', [StoreGenerationController::class, 'generate'])->name('stores.generate');
  79. Route::post('stores/{slug}/edits', [StoreGenerationController::class, 'edit'])->name('stores.edits');
  80. });
  81. require __DIR__.'/settings.php';