Is there any relationships between those tables?
1 Form many input data for different tables.
Basically, i have one form with many inputs for different tables. For example, one form with many inputs for Personal Information [Table 1], Address [Table 1] and Payment Info [Table 1] using the Form Facade for Post method via a Controller [user@create]. My initial solution is to store the data one by one to its equivalent column in the database. Is there any way to make this easier or how should this be handle properly? See sample table below.
Tables:
- USER - 5 columns
- Address - 3 columns
- Payment Info - 5 columns.
One Form and One Controller.
$user = new App\User; $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); .........
$address = new App\Address; $address->city = Input::get('city'); ...........
$payment = new App\Payment; $payment->account_num = Input::get('acct_num'); ........
You ca do this
$address = new App\Address(['city' = Input::get('city')]);
$payment = new App\Payment(['account_num' = Input::get('acct_num')]);
$user = User::create(Input::all());
$user->address()->save($address);
$user->payment()->save($payment);
Please or to participate in this conversation.