| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
-
- namespace App\Http\Controllers;
-
- use App\Http\Controllers\Concerns\RendersStorefront;
- use App\StorePlan\PlanSchema;
- use Illuminate\Http\Request;
- use Inertia\Response;
-
- /**
- * The storefront pages: home, shop and product.
- */
- class StoreDesignController extends Controller
- {
- use RendersStorefront;
-
- /**
- * The home page of the storefront, drawn from the store's saved plan.
- */
- public function preview(Request $request, string $slug): Response
- {
- return $this->renderStorefront($request, $this->ownedStore($request, $slug), [
- 'type' => 'page',
- 'pageId' => PlanSchema::HOME_PAGE,
- ]);
- }
-
- /**
- * The shop page: every product shoppers may see.
- */
- public function shop(Request $request, string $slug): Response
- {
- return $this->renderStorefront($request, $this->ownedStore($request, $slug), ['type' => 'shop']);
- }
-
- /**
- * One product's own page.
- */
- public function product(Request $request, string $slug, string $productSlug): Response
- {
- $store = $this->ownedStore($request, $slug);
-
- $product = $store->products()->active()->with('images')->where('slug', $productSlug)->firstOrFail();
-
- return $this->renderStorefront($request, $store, ['type' => 'product', 'product' => $product->toStorefront()]);
- }
- }
|