<x-app-layout>
    @section('title')
        Pages Management
    @endsection
    <!-- Page Heading -->
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">
                Categories
            </h6>
        </div>
        <div class="card-body">
            <form method="POST" action="{{ route('admin.startSetting.update',$data->id) }}">
                @csrf
                @method('put')
                <div class="row">
                    <div class="col-12">
                        <label for="title">Title</label>
                        <input type="text" name="title" id="title" value="{{ $data->title }}" placeholder="Title" class="form-control">
                    </div>
                    <div class="col-12 mt-3">
                        <div>
                            <label for="description">Description</label>
                            <button type="button" class="btn btn-primary float-right" id="addmore">Add more</button>
                        </div>
                        @foreach ($data->startpagesettingdetails as $content)
                            <div id="description-container">
                                <textarea name="description[]" class="form-control summernote">{{ $content->details }}</textarea>
                            </div>
                        @endforeach

                    </div>
                    <div class="col-12 mt-3">
                       <button class="btn btn-primary">Update</button>
                    </div>
                </div>

            </form>
        </div>
    </div>

    <script>
        $(document).ready(function(){
            // Event listener for the "Add more" button
            $('#addmore').click(function() {
                addTextarea();
            });

            // Function to generate new textarea
            function addTextarea() {
                var newTextarea = '<textarea name="description[]" class="form-control summernote"></textarea>';
                $('#description-container').append(newTextarea);
                $('.summernote').summernote();

            }
        });
        </script>
</x-app-layout>
