<x-app-layout>
    <x-slot name="header">
        <div class="row">
            <div class="col-6">
                <h4 class="" title><i class="circular icon fa fa-list"></i> {{ __('List Accounts')  }} </h4>
            </div>
        </div>
    </x-slot>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    {{$dataTable->table()}}
                </div>
            </div>
        </div>  
    </div>


    <x-slot name="after_script">
        <script src="/bower_components/admin-lte/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
        {{$dataTable->scripts()}}
        <script>
                var app = new Vue({
                    el: '#app',
                    data:{
                        table: "accounts-table",
                    },
                    mounted:function(){
                        const vm = this; 
                        $(document).on('draw.dt',function(e){
                            vm.$root.load = false;
                            $("input[data-bootstrap-switch]").each(function() {
                                $(this).bootstrapSwitch('state', $(this).prop('checked'));
                                $(this).on('switchChange.bootstrapSwitch', function() {
                                    var id = $(this).data('id');
                                    axios.put("/accounts/" + id)
                                        .then(res => {
                                            vm.reload();
                                        });
                                });
                            });
                        });
                    },
                    methods: {
                        
                    }
                })
        </script>
        
    </x-slot>
</x-app-layout>
