Latest

Thursday, July 13, 2017

The easiest way to insert multiple tables from one form

Asked by: Adriani Umar


in laravel i want to insert into two tables the data from one form.

my forms are:

<input type="text" name="name"class="form-control">
<input type="text" name="age"class="form-control">
<input type="text" name="sex"class="form-control">
<input type="text" name="location"class="form-control">

i want to insert the name, age, and sex to table details. and input location to table locations

location model belongsTo detail model.

how to insert them at the same time? and how to automatically match the id of detail with detail_id of location?

i have search but too difficult to follow. i wish there's an easy way to follow.



Source

No comments:

Post a Comment

Adbox