<script type="text/javascript">
    $(document).ready(function (){

        $('#hnts').on('click',function (){
            var hints_url = '/activate-hints/'+{{auth()->user()->id}};
            var datas = $('#toggleswitch').serializeArray();

            $.ajax({
                type: 'POST',
                url: hints_url,
                dataType: "json",
                data: datas ,
                success: function (res) {
                    /*if(res == 1){
                        alert('System Hints have successfully been turned on');
                    }else if(res == 0){
                        alert('System Hints have successfully been turned Off');
                    }*/
                    location.reload();
                }
            });
        });

    });
</script>

{!! Form::model(isset($user) ?? [],['route'=>['libs.hints.update','id'=>$user->id], 'method'=>'POST', 'id'=>'toggleswitch']) !!}
    <i class="fa fa-bars" aria-hidden="true"></i> &nbsp;&nbsp;&nbsp;&nbsp;
    Hints <label class="switch">
        <input id="hnts" name="turn-hints" type="checkbox" @if($user->hints == 1) value="0" checked @else value="1" @endif >
    <span class="slider round" ><span style="margin-left: 2px; color: white">On</span></span>
    </label>
{!! Form::close() !!}

