lundi 21 décembre 2015

Data is not getting stored in database for multiple check box in laravel

I have created a form, in which I have a list of days to be selected multiple. But those days are not getting stored in database.

here is my controller:

public function store(EventRequest $request)
{
    $input = Request::all();
    $input['days_of_week'] = Input::get('days_of_week');
    Event::create($input);
    return redirect('event');
}

and my view is:

    @foreach($days as $day)
    <ul>
        <li>
            {!! Form::checkbox("days_of_week[]", $day, null) , $day !!}
        </li>
    </ul>
    @endforeach

when I return Input::get('days_of_week'); it displays the check boxes I select.

How can I store checkbox value along with all the other fields present in form.




Aucun commentaire:

Enregistrer un commentaire