<?php
use App\Models\Permission;
?>

<h2>Permessi per il ruolo <i>{{ $role->name }}</i> </h2>

{!! Form::open(['method' => 'POST', 'route' => ['roles.updatePermission']]) !!}
{!! Form::hidden('role_id', $role->id) !!}

@foreach(Permission::select('permissions.*')->groupBy('group')->orderBy('group', 'ASC')->get() as $group)
<h3>{{ $group->group }}</h3>
<ul style="list-style-type:none">
  @foreach(Permission::where('group', $group->group)->orderBy('name', 'ASC')->get() as $permission)
  <li>{!! Form::checkbox('permesso[]', $permission->id, $role->hasPermissionTo($permission->name), ['class' => '']) !!} {{ $permission->display_name }}</li>
  @endforeach
</ul>
@endforeach

{!! Form::submit('Salva', ['class' => 'btn btn-primary form-control']) !!}
{!! Form::close() !!}
