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.

StoreDesignController.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Store;
  4. use App\StorePlan\PlanSchema;
  5. use App\StorePlan\PlanValidator;
  6. use App\StorePlan\SamplePlan;
  7. use Illuminate\Http\RedirectResponse;
  8. use Illuminate\Http\Request;
  9. use Inertia\Inertia;
  10. use Inertia\Response;
  11. class StoreDesignController extends Controller
  12. {
  13. /**
  14. * Show the storefront as a full page, drawn from the store's saved plan.
  15. */
  16. public function preview(Request $request, string $slug): Response
  17. {
  18. $store = $this->ownedStore($request, $slug);
  19. abort_if($store->plan === null, 404);
  20. return Inertia::render('stores/preview', [
  21. 'storeName' => $store->name,
  22. 'language' => $store->language->value,
  23. 'plan' => $store->plan,
  24. 'fonts' => PlanSchema::FONTS,
  25. ]);
  26. }
  27. /**
  28. * Give the store the hand-written sample design.
  29. * Temporary: this is replaced by AI generation in Step 3.
  30. */
  31. public function applySample(Request $request, PlanValidator $validator, string $slug): RedirectResponse
  32. {
  33. $store = $this->ownedStore($request, $slug);
  34. $store->plan = $validator->validate(SamplePlan::for($store));
  35. $store->save();
  36. Inertia::flash('toast', ['type' => 'success', 'message' => __('Sample design applied.')]);
  37. return to_route('stores.show', $store->slug);
  38. }
  39. private function ownedStore(Request $request, string $slug): Store
  40. {
  41. return $request->user()->stores()->where('slug', $slug)->firstOrFail();
  42. }
  43. }