Reputation: 35
How should I save values of form in two different tables in database using laravel. I have two tables one is saving only email and password, second is storing other information of user. How should I do this?
Upvotes: 0
Views: 1468
Reputation: 7535
Have the form send to a particular Controller method and Store the pertinent data in their relative Models:
public function store(Request $request)
{
User::create([
'email' => $request->email,
'password' => Hash::make($request->password)
]);
Profile::create([
'website' => $request->website,
'address' => $request->address,
// etc...
]);
}
Upvotes: 4