request value from a checkbox in laravel

0

I need to get the value of this checkbox but nothing is working.

@foreach ($options->getGenresEventos() as $agenda)
 <input type="checkbox" name="cat" id="cat" class="checkbox" value="{{strtolower($agenda)}}" data-bind="checked: params.genres"/> {{ $agenda }}<br><br>
@endforeach

I did so

<input type="hidden" name="city" value="@if(Input::get('genre')){{Input::get('genre')}} @else {{Request::('cat')}} @endif" />

Thanks for any help

    
asked by anonymous 29.12.2017 / 19:10

1 answer

0

Just set the checkbox in HTML.

So with pure HTML

<input type="checkbox" name="status" value="1">

and so with laravel collective

{!! Form::checkbox('status') !!}

If the checkbox is not selected it will not send to the controller via the request. so you can check the controller like this:

$dataForm = $request->all();

$dataForm['status'] = (!isset($dataForm['status']))? 0 : 1;
    
29.12.2017 / 19:17