I have a form like this:
What I want is that when selecting two or more sports, add a row for each sport with the id of the selected name, until now in my database is stored as follows:
And here is my Controller code:
$data = new Id;
if(isset($_POST["save"])){
$names = $_POST["names"];
$sports =$_POST["sports"];
$array = implode(', ', $sports);
$data->name = $names;
$data->sport = $array;
$data->save();
$ids = Id::all();
return view('data', ['ids'=>$ids]);
}