I have this model
public function exercicio()
{
return $this->belongsToMany(Exercicio::class);
}
and
public function treino()
{
return $this->belongsToMany(Treino::class);
}
My Controller
public function salvarTreino(Request $request)
{
}
How do I save a workout list?
It's currently like this
public function salvarTreino(Request $request)
{
$treino = new Treino();
$treino->nome = $request->nome;
$treino->save();
$treino->exercicio()->attach([1]);
return response()->json("", 201);
}
however I am manually passing the exercise id, I want the user to be able to choose