lundi 21 novembre 2016

Laravel form collective checkbox

so how can I make a default checked/unchecked checkbox, with values from the data base? I'm using Form model from laravel collective and my checkbox field is this:

Form::model($role, ['route' => ['the_route', $role->slug], 'method' => 'patch'])

    @foreach ($permissions as $permission)
        Form::checkbox('permission['.$permission->slug.']', 'true', null, ['class' => 'square'])
    @endforeach

Form::close()

The thing is that $role->permissions returns an array like this:

array:3 [
  "dashboard.view" => "false"
  "user.view" => "true"
  "user.edit" => "false"
]




Aucun commentaire:

Enregistrer un commentaire