@props([ 'name' => 'menu', // input name for JSON 'value' => '[]', // initial JSON (string or array) 'id' => null, // optional DOM id 'maxDepth' => null, // optional nesting limit (null = unlimited) ])
merge(['class' => 'menu-builder ']) }} x-data="menuBuilder({ initial: @js($value), maxDepth: @js($maxDepth) })" x-init="init()" :id="$id">
@csrf
{{ __('Add Menu Item') }}

{{ __('Menu Structure') }} {{ __('Drag to reorder or nest items') }}
@once {{-- --}} @endonce {{-- USAGE 3) In your controller: $validated = $request->validate([ 'menu' => ['required','json'], ]); $tree = json_decode($validated['menu'], true); // store $tree as JSON or flatten to menu_items table (parent_id, order, title, url, blank) 4) To edit (update action), pass existing JSON to :value. Component loads and serializes automatically. NOTE: - Set :max-depth to limit nesting (e.g., 3). Null = unlimited. --}}