Hi, my goal is to save single form data to multiple tables of database. When I have two models say "Product" and "Seller", and one form where seller creates a new product. If I keep product and seller models in relationship, and when I submit the form, does Laravel 5.4 automatically saves the respective data to both the tables? (Seller information to sellers table and product information to products table).
I believe you need to do that manually. Create the seller (and add its records to the DB) and use the seller id to add the products:
$seller = Seller::create($seller_info_array);
Use $seller->id as foreign_key to create the product or products you need add.
Product::create(['seller_id'=>$seller_id,..rest of fields as array items..]);
Sign in to participate in this thread!