user()->stores()->where('slug', $slug)->firstOrFail(); abort_if($store->plan === null, 404); $type = SectionLayouts::typeOf($store->plan, $sectionId); abort_if($type === null, 404); $validated = $request->validate([ 'variant' => ['required', Rule::in(PlanSchema::SECTIONS[$type])], ]); $store->plan = $validator->validate(SectionLayouts::update($store->plan, $sectionId, $validated['variant'])); $store->save(); Inertia::flash('toast', ['type' => 'success', 'message' => $store->isPublished() ? __('Saved. Click "Publish changes" to show it on your live store.') : __('Layout saved.')]); return to_route('stores.show', $store->slug); } }