I wanna know that it is correctly to something like this. In my database i have table with users and photos. Every one user has exactly one picture. I have
one view with form which is route post to UsersController to store method.
UsersController
public function store(Request $request)
{
// some validation
$user = new Users();
$user->name = $request->input('name')
.....
if($user->save())
{
if($request->hasFile('photo'))
{
$photo = new Photos();
....
$photo->save();
return redirect......
}
}
}
It is correctly to insert data from one controller to muliple tables. In this example it's only one additional table but every know there may be more of them.