list - Larevel pivot table perimissions chack -


when click on role detail lists permissions .

my controller :

    public function permissions($id) {     $all_permissions = permission::all(); // permissions      $role = role::with('permissions')->where('id', '=', $id)->get(); // role , role permissions      return view('auth.permissions',compact('role','all_permission')); } 

all permissions in role of pivot tables list permissions want selected

enter image description here

my view file:

@foreach($role $rol)    {{ $rol->name }}   <tbody>  @foreach($all_permissions $permision)      <tr>          <td> {{ $permision->id }} </td>          <td> {{ $permision->name }}</td>          <td> {{ $permision->label }} </td>          <td> {{ $permision->updates_at }} </td>          <td>              <input type="checkbox" class="make-switch" checked data-size="small" data-on-color="success" data-on-text="yes" data-off-color="danger" data-off-text="hayir"> </li>                                              </td>      </tr>   @endforeach     </tbody>   @endforeach  

thanks help.

i think "contains" method have wanted:

this sample 1 of live projects:

@foreach ($permissions $permission) <tr>     <td><label class="css-input css-checkbox css-checkbox-primary">     {!! form::checkbox('permissions['.$permission->id.']', $permission->id, $role->permissions->contains($permission->id)) !!}<span></span></label></td>     <td>{{ $permission->title }}</td>     <td>{{ $permission->slug }}</td>     <td>{{ $permission->description }}</td> </tr> @endforeach  

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -