I have a table of students and another table of documents, they have a ratio of 1: 1 How can I insert a record in a document in which I am asked for the student's id? to bring me the id of a student that already exists and insert with that id.
I have a table of students and another table of documents, they have a ratio of 1: 1 How can I insert a record in a document in which I am asked for the student's id? to bring me the id of a student that already exists and insert with that id.
Let's see if I understood your question. You get the student ID according to a condition, for example:
$id_alumno = Alumno::where("nombre","=","pepito")->value("id_alumno");
Then insert the row of the document:
$documento = new Documento();
$documento->id_alumno = $id_alumno;
$documento->save();