| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
-
- use App\Http\Controllers\BillingController;
- use App\Http\Controllers\CartController;
- use App\Http\Controllers\CheckoutController;
- use App\Http\Controllers\OrderController;
- use App\Http\Controllers\ProductController;
- use App\Http\Controllers\StoreController;
- use App\Http\Controllers\StoreDesignController;
- use App\Http\Controllers\StoreGenerationController;
- use App\Http\Controllers\StorePublishController;
- use App\Http\Controllers\StoreSettingsController;
- use App\Http\Controllers\StripeWebhookController;
- use Illuminate\Support\Facades\Route;
-
- /*
- |--------------------------------------------------------------------------
- | Live stores
- |--------------------------------------------------------------------------
- |
- | A published store has its own address: "<store name>.<domain>", such as
- | sambal-nenek.localhost. Shoppers need no login. These routes are listed
- | first so that on a store's address nothing else of the app can be opened.
- |
- */
- Route::domain('{storeSlug}.'.config('storefront.domain'))
- ->middleware('throttle:240,1')
- ->name('storefront.')
- ->group(function () {
- Route::get('/', [StoreDesignController::class, 'preview'])->name('home');
- Route::get('shop', [StoreDesignController::class, 'shop'])->name('shop');
- Route::get('products/{productSlug}', [StoreDesignController::class, 'product'])->name('product');
-
- Route::get('cart', [CartController::class, 'show'])->name('cart');
- Route::post('cart/items', [CartController::class, 'add'])->name('cart.add');
- Route::patch('cart/items/{product}', [CartController::class, 'update'])->name('cart.update')->whereNumber('product');
- Route::delete('cart/items/{product}', [CartController::class, 'remove'])->name('cart.remove')->whereNumber('product');
-
- Route::get('checkout', [CheckoutController::class, 'show'])->name('checkout');
- Route::post('checkout', [CheckoutController::class, 'store'])->middleware('throttle:20,1')->name('checkout.store');
- Route::get('orders/{publicId}', [CheckoutController::class, 'order'])->name('order');
-
- // Pages the merchant added, such as /about.
- Route::get('{pageId}', [StoreDesignController::class, 'page'])->name('page')->where('pageId', '[a-z][a-z0-9-]*');
-
- // Anything else on a store's address does not exist. This hides the dashboard and login pages there.
- Route::any('{any}', fn () => abort(404))->where('any', '.*')->name('missing');
- });
-
- Route::inertia('/', 'welcome')->name('home');
-
- // Called by Stripe, not by a browser, so it has no login. Each message is checked with a signing secret.
- Route::post('stripe/webhook', StripeWebhookController::class)->name('stripe.webhook');
-
- Route::middleware(['auth', 'verified'])->group(function () {
- Route::get('dashboard', [StoreController::class, 'index'])->name('dashboard');
-
- Route::get('billing', [BillingController::class, 'index'])->name('billing');
- Route::post('billing/subscribe', [BillingController::class, 'subscribe'])->name('billing.subscribe');
- Route::post('billing/cancel', [BillingController::class, 'cancel'])->name('billing.cancel');
- Route::post('billing/resume', [BillingController::class, 'resume'])->name('billing.resume');
-
- Route::get('stores/create', [StoreController::class, 'create'])->name('stores.create');
- Route::post('stores', [StoreController::class, 'store'])->name('stores.store');
- Route::get('stores/{slug}', [StoreController::class, 'show'])->name('stores.show');
- Route::get('stores/{slug}/preview', [StoreDesignController::class, 'preview'])->name('stores.preview');
- Route::get('stores/{slug}/preview/shop', [StoreDesignController::class, 'shop'])->name('stores.preview.shop');
- Route::get('stores/{slug}/preview/products/{productSlug}', [StoreDesignController::class, 'product'])->name('stores.preview.product');
-
- Route::get('stores/{slug}/preview/cart', [CartController::class, 'show'])->name('stores.preview.cart');
- Route::post('stores/{slug}/preview/cart/items', [CartController::class, 'add'])->name('stores.preview.cart.add');
- Route::patch('stores/{slug}/preview/cart/items/{product}', [CartController::class, 'update'])->name('stores.preview.cart.update')->whereNumber('product');
- Route::delete('stores/{slug}/preview/cart/items/{product}', [CartController::class, 'remove'])->name('stores.preview.cart.remove')->whereNumber('product');
-
- Route::get('stores/{slug}/preview/checkout', [CheckoutController::class, 'show'])->name('stores.preview.checkout');
- Route::post('stores/{slug}/preview/checkout', [CheckoutController::class, 'store'])->name('stores.preview.checkout.store');
- Route::get('stores/{slug}/preview/orders/{publicId}', [CheckoutController::class, 'order'])->name('stores.preview.order');
-
- // Pages the merchant added, such as /about. Listed after the store's own pages so those win.
- Route::get('stores/{slug}/preview/{pageId}', [StoreDesignController::class, 'page'])->name('stores.preview.page')->where('pageId', '[a-z][a-z0-9-]*');
-
- Route::get('stores/{slug}/orders', [OrderController::class, 'index'])->name('stores.orders.index');
- Route::get('stores/{slug}/orders/{order}', [OrderController::class, 'show'])->name('stores.orders.show')->whereNumber('order');
- Route::post('stores/{slug}/orders/{order}/ship', [OrderController::class, 'ship'])->name('stores.orders.ship')->whereNumber('order');
-
- Route::get('stores/{slug}/products', [ProductController::class, 'index'])->name('stores.products.index');
- Route::get('stores/{slug}/products/create', [ProductController::class, 'create'])->name('stores.products.create');
- Route::post('stores/{slug}/products', [ProductController::class, 'store'])->name('stores.products.store');
- Route::get('stores/{slug}/products/{product}/edit', [ProductController::class, 'edit'])->name('stores.products.edit')->whereNumber('product');
- // Saving uses POST, not PUT, because browsers can only upload files with POST.
- Route::post('stores/{slug}/products/{product}', [ProductController::class, 'update'])->name('stores.products.update')->whereNumber('product');
- Route::delete('stores/{slug}/products/{product}', [ProductController::class, 'destroy'])->name('stores.products.destroy')->whereNumber('product');
- Route::delete('stores/{slug}/products/{product}/images/{image}', [ProductController::class, 'destroyImage'])->name('stores.products.images.destroy')->whereNumber(['product', 'image']);
- Route::get('stores/{slug}/settings', [StoreSettingsController::class, 'edit'])->name('stores.settings');
- Route::put('stores/{slug}/settings', [StoreSettingsController::class, 'update'])->name('stores.settings.update');
- Route::post('stores/{slug}/publish', [StorePublishController::class, 'publish'])->name('stores.publish');
- Route::post('stores/{slug}/unpublish', [StorePublishController::class, 'unpublish'])->name('stores.unpublish');
- Route::post('stores/{slug}/generate', [StoreGenerationController::class, 'generate'])->name('stores.generate');
- Route::post('stores/{slug}/edits', [StoreGenerationController::class, 'edit'])->name('stores.edits');
- });
-
- require __DIR__.'/settings.php';
|