Home > database >  htmlspecialchars() expects parameter 1 to be string, array given using laravel
htmlspecialchars() expects parameter 1 to be string, array given using laravel

Time:10-12

I am trying to show array dates in check-in variable from the controller but unfortunately, I am getting error please help me how can resolve that thanks.

Please check the error here

https://flareapp.io/share/dmkyk4l7

return $dates

[
  "01-10-2021",
  "02-10-2021",
  "03-10-2021",
  "04-10-2021"
]

jquery script

<script type="text/javascript">
    let checkInn = "{{ $dates }}";
    // var checkInn = ["10-10-2021", "10-10-2021"];
    $('.datepicker').datepicker({
        format: 'mm/dd/yyyy',
        beforeShowDay: function(date) {
            dmy = date.getDate()   "-"   (date.getMonth()   1)   "-"   date.getFullYear();
            if (checkInn.indexOf(dmy) != -1) {
                return false;
            } else {
                return true;
            }
        }
    });
</script>

CodePudding user response:

Try this one , you need to use @json()

<script type="text/javascript">
     
       let checkInn =  @json($array);
      // var checkInn = ["10-10-2021","10-10-2021"];
      $('.datepicker').datepicker({
          format: 'mm/dd/yyyy',
          beforeShowDay: function(date){
              dmy = date.getDate()   "-"   (date.getMonth()   1)   "-"   date.getFullYear();
              if(checkInn.indexOf(dmy) != -1){
                  return false;
              }
              else{
                  return true;
              }
          }
      });
    </script>
  • Related