3👍
✅
First of all assign all the this.rows
to a data set then push it to the axios call something like this:
saveData(){
const postData = {
data: this.rows
}
this.axios.post('/addperson', postData).then((response) => {
console.log("WOW");
})
}
Now in laravel
controller you can use foreach
to use this data set.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\OrderPerson;
class PersonController extends Controller
{
public function create(Request $request){
foreach($request->data as $data)
{
$container = new Person([
'name' => $data['name'],
'age' => $data['age'],
'user_id' => $data['user_id']
]);
$container->save();
}
return response()->json('Successfully added');
}
}
Hope this helps.
Source:stackexchange.com