theUnforgiven
4 months ago
60
5
Vue

Passing Vue arrays to Laravel

Posted 4 months ago by theUnforgiven

I have the following data in my Vue file, of which I need to pass to Laravel in order to save the data.

I have a method like so:

 submit(e) {
      var form = document.getElementById("form");
      var formData = new FormData(form);

      axios.post("/block/save", formData).then(
        response => {
          // success callback
          console.log("Success");
        },
        response => {
          // error callback
          console.log("ERROR!");
          console.log(response.data);
        }
      );
    }

Then dd() $request->all(); shows the following:

 "block_name" => "fsd"
  "no_of_units" => "3"
  "floors" => "2"
  "lift" => "no"
  "address" => "Some Address Two"
  "facility" => array:4 [
    0 => "fob"
    1 => "gate_entry"
    2 => "finger"
    3 => "bike_storage"
  ]
  "block" => array:1 [
    "unit" => "3"
  ]

But it's not showing the blocks array in which I need it to so I can save each row.

Please sign in or create an account to participate in this conversation.