php - Laravel 5.3 Eloquent - How to post data to multiple tables with a form?


So far I can only post data to 1 table with a form.

My controller:

public function store(Request $request, Role $role)


    return redirect('/roles');

My view:

<div >
  <label for="name-input">@lang('')</label>
  <input id="name-input" type="text" name="name" value="{{ isset($role) ? $role->name : '' }}" autofocus>

<div >
  <label for="description-input">@lang('role.description_optional')</label>
  <textarea id="description-input" name="description" >{{ isset($role) ? $role->description : '' }}</textarea>            

So it perfectly stores thename anddescription, but what if I wanted to store data to a second table?




Something like this

$second = new SecondTableModel(); 

People are also looking for solutions to the problem: php - Add middleware after login in laravel


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.