vendredi 28 décembre 2018

Laravel - Highlighting roles which are already assigned to a user

On user\edit view I'm displaying all roles as checkboxes. I'd like to have roles which are already assigned to a user checked. All other fields in the form are filled in with details from the database already. I'm trying to work with Spatie's Laravel Permissions.

Image of the view

@foreach ($roles as $role)
    <input type="checkbox" value="" name="" > </input>
@endforeach

I would like to use pure HTML. I read about eager loading but from what I understood it will give me only roles assigned to a user, not all of them.

I want to use sychRoles() function when I click update button. I was hoping to build similar view to what Voyager uses: example.




Aucun commentaire:

Enregistrer un commentaire