I'm new to Laravel and php and have been researching ways to submit different forms. The form I making now is a check box of interests that will submit to a follower table. So far I have it that each interest has it's specific value equal which will be used to display all articles associated with the interest_id.
Now I'm kind of stuck on the manner to submit the interests. I couldn't find any approaches of submitting multiple rows from one form. So now I made them multiple forms which works however I have to put a submit button on each.
Is there anyway to submit more than one form on a single submit button or a way to submit more than one row on one form?
Here is the code i have now...
html:
<div class="panel-body">
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
{!! Form::open() !!}
<div class="form-group">
<div class="col-md-6">
{!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
{!! Form::checkbox('interest_id', '1', true) !!}
</div>
</div>
{!! Form::close() !!}
{!! Form::open() !!}
<div class="form-group">
<div class="col-md-6">
{!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
{!! Form::checkbox('interest_id', '2', true) !!}
</div>
</div>
{!! Form:: submit('Sumbit', ['class' => 'btn btn-primary form-control']) !!}
{!! Form::close() !!}
</div>
store function on my interestcontroller:
public function store(InterestRequest $interest)
{
$interest = new Follower(array(
'user_id' => $interest->get('interest_id'),
'follower_id' => Auth::id()
));
$interest->save();
}