<x-backend.model :id="'slide-edit-model'" class="lg:max-w-2xl" :button="'Submit'" :form_id="'slide-edit'" :action="route('slider.store')"
    :method="__('post')">
    @csrf
    @method('put')
    <div class="p-4 sm:p-10 overflow-y-auto  space-y-2">
        <x-backend.editor name='content' :height="__('200px')" :full="false" :id="'edit'" :form_id="'slide-edit'"
            :validate="true" />
        <x-backend.input-label :value="__('Button Name')" for="button_name" />
        <x-backend.input-field type="text" name="btn_name" id='button_name' :value="old('button_name')"
            placeholder="Enter button name" />

        <x-backend.input-label :value="__('Button URL')" for="button_url" />
        <x-backend.input-field type="text" name="btn_url" id='button_url' placeholder="Enter button url"
            :value="old('button_url')" />
        <x-backend.input-label :value="__('Upload Image')" for="upload_image" />
        <x-backend.input-field type="file" name="image" id='upload_image'
            class="block w-full text-sm text-gray-500 -ml-2
    file:me-4 file:py-2 file:px-4
    file:rounded-lg file:border-0
    file:text-sm file:font-semibold
    file:bg-blue-600 file:text-white
    hover:file:bg-blue-700
    file:disabled:opacity-50 file:disabled:pointer-events-none
    dark:file:bg-blue-500
    dark:hover:file:bg-blue-400
  " />
    </div>
</x-backend.model>



<script>
    $(document).on('click', '#update', function() {
        let data = $(this).attr('data');

        data = JSON.parse(data);

        $('#slide-edit').find('#button_name').val(data.btn_name);
        $('#slide-edit').find('#button_url').val(data.btn_url);
        // Get the Froala Editor instance
        var editor = new FroalaEditor('#edit');
        // Set the content of the editor
        editor.html.set(data.content);
        let route = "{{ route('slider.update', ':id') }}".replace(':id', data.id);
        $('#slide-edit').attr('action', route)
    })
</script>
