0
I’ve read questions about it, but I still can’t solve my problem.
Here’s the thing, I have a separate Laravel view to register user. Ai in theory should redirect to another view where it will provide other user data. However, I am not able to send the id of this insertion from the first view to the second one and make the relationship between them. Here is the user controller the function where you insert in the database and then return to another view
public function store(Request $request, User $user) {
$dataform = $request->except('_token');
$insert = $user->insert($dataform);
if ($insert) {
return view('instrutor',compact('dataform')); //Queria que enviasse somente o ID.
} else {
return redirect()->back();
}
}
And here the controller function where you should receive the ID and insert the form data into the instructor table and attach the user id.
public function store(Request $request, Instrutor $instrutor) {
//
$dataform = $request->except('_token');
$insert = $instrutor->insert($dataform);
if ($instrutor) {
return redirect()->route('index');
} else {
return redirect()->back();
}
}
There are two different users and instructor tables, where instructor is related to foreign key users
Hello @Cleber-Martins, interesting your idea but how will I specifically take the $dataform id field?
– R. Pêgo
Sorry, I must have misunderstood. You want to recover the ID inserted in the User table for then in the Instructor table.
– Cleber Martins
Type, I registered the user email and password sent to the bank now redirects to the Instructor & #Xa; screen need this previously registered user id to link it to the instructor.
– R. Pêgo