I'm using form::model
to edit data. It works correctly but the checkboxes return empty. How do I return the ones saved in bd?
I want them to show the ones that are registered. For example: in the course register I marked Morning and afternoon, so in the edition you have to return the two marked and one more empty, in the Night case.
[v] Morning [v] Afternoon [] Night
View edit:
{{ Form::model($curso, array('method' => 'PATCH', 'route' => array('painel.cursos.update', $curso->id))) }}
<label>{{ Form::checkbox( 'turnos[0]', 'Manhã') }} Manhã</label>
<label>{{ Form::checkbox( 'turnos[1]', 'Tarde') }} Tarde</label>
<label>{{ Form::checkbox( 'turnos[2]', 'Noite') }} Noite</label>
{{ Form::close() }}
So they return empty.
Already in this way, they only retrieve the saved ones in bd:
<?php $course = explode(",", $curso->turno);?>
@foreach ($course as $c)
<label>{{ Form::checkbox('turnos[]', $c, true) }} {{$c}}</label>
@endforeach
I'm not sure how to do this.