{!! Form::open(['route' => ['admin.payments.destroy', $id], 'method' => 'delete']) !!}
<div class='btn-group'>
    @ability('super-admin' ,'payments.show')
    <a href="{{ route('admin.payments.show', $id) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-eye-open"></i>
    </a>
    @endability
    @ability('super-admin' ,'payments.edit')
    <a href="{{ route('admin.payments.edit', $id) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-edit"></i>
    </a>
    @if(\Auth::id() == 1 || \Auth::id() == 2)
        @if($model->status == 1)
            <input type="checkbox" name="status" data-toggle="toggle" data-on="PAID" data-off="Disabled"
                   class="status" data-value="{{ $id }}" checked id="get_status{{ $id }}">

        @else

            <input type="checkbox" name="status" data-toggle="toggle" data-on="Enabled" data-off="Disabled"
                   class="status" data-value="{{ $id }}" id="get_status{{ $id }}">

        @endif
    @endif
    @endability
    @ability('super-admin' ,'payments.destroy')
    {!! Form::button('<i class="glyphicon glyphicon-trash"></i>', [
        'type' => 'submit',
        'class' => 'btn btn-danger btn-xs',
        'onclick' => "confirmDelete($(this).parents('form')[0]); return false;"
    ]) !!}
    @endability
</div>

{!! Form::close() !!}


<script type="text/javascript">
    $(function () {
        $('input[type="checkbox"]').bootstrapToggle({
            on: 'Enabled',
            off: 'Disabled'
        });
    });

    $("#get_status{{ $model->id }}").change(function () {
        var i = $(this).data("value");
        statusChangepay(i);
        return false;
    });

    function statusChangepay(id) {
        console.log(id);
        $.ajax({
            url: "statusChangePay/" + id,
            method: 'GET'
        }).done(function (response) {
            if (response === 'Success') {
                swal({
                    title: "Success",
                    icon: "success"
                }).then(function () {
                    location.reload();
                });
            } else {
                location.reload();
            }

        });
    }


</script>
