mercredi 5 août 2015

Using foreach with form submit


I am trying to submit multiple rows using the foreach loop in my method. However when I press submit I am getting this array to string error. How do I fix this error?

Error

Array to string conversion

HTML

{!! Form::open(array('id'=> 'form1')) !!}
    <div class = "form-group">
        <div class="col-md-6">
            {!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
            {!! Form::checkbox('interest_id', '1', ['class' => 'formclick submit']) !!}
        </div>
    </div>

    <div class = "form-group">
        <div class="col-md-6">
            {!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
            {!! Form::checkbox('interest_id', '2',['class' => 'formclick submit']) !!}
        </div>
    </div>
    <input id = "submit_me" type="button" value="Click Me!"  />
{!! Form::close() !!}

Controller

public function store(InterestRequest $interest) {

    $interests = Request::all();
    $interests = Request::all();

    foreach ($interest-> $interests as $inter) {
        $interest = new Follower(array(
            'user_id' => $interest->get('interest_id'),
            'follower_id'  => Auth::id()
        ));

        $inter->save();

    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire