I am new to laravel and i want to insert the data into two different tables using one form submission. Example i want to insert the user's account info into "tbl_users" (e.g. Email, Password) and the user's info will be inserted into "tbl_client" (e.g. Name,Bday,Address).By the way i am just using the laravel default auth register (User.php, RegisterController.php). Is there is a safest way to do that ?.
You could use an observer. You can then on saved
or saving
of the user model, create a new client, from there filling it with the data used to create user. You could use the global request()
to get the submitted data.
Another way would be, on model construct create a new client from there. So in your user.php
model, something like:
public function __construct(array $attributes)
{
parent::__construct($attributes);
new Client()
}
and then proceed to fill the client.