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?
-
pleas give me sample code or tutorial related to thisPrashant– Prashant2015-11-30 11:09:42 +00:00Commented Nov 30, 2015 at 11:09
-
Can you show us the Models you've created so far as well as the Controller method where you are saving the data?Josh Rumbut– Josh Rumbut2015-11-30 14:12:53 +00:00Commented Nov 30, 2015 at 14:12
-
1Have you tried anything?smartrahat– smartrahat2015-11-30 14:28:09 +00:00Commented Nov 30, 2015 at 14:28
Add a comment
|
1 Answer
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...
]);
}