I've read about this, but I still can not solve my problem.
is as follows, I have a separate Laravel view to register user. Ai in theory should redirect to another view where it will provide other user data. But I am not able to send the id of this insert from the first view to the second and make the relation between them. Here is the controller user the function where you would insert into the bank 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 is the controller's 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 tables users and instructor, where instructor is related to users with foreign key