title: How do I match users permission with all the permissions in the database
body: <p>I'm trying to get the user role with permissions and compare them with all permissions that are in the database, if they match then a checkbox should be checked... I'm not sure if I'm doing it correctly</p>
  <p><strong>RoleController</strong> :</p>
  <pre><code>public function edit($id)
  {
      $role =Role::where('id', $id)-&gt;with('permissions')-&gt;first();
      $permissions = Permission::all();
      return view('admin.roles.edit', compact('role', 'permissions'));
  }
  </code></pre>
  <p><strong>edit.blade.php</strong> :</p>
  <pre><code>&lt;table class=&quot;table&quot;&gt;
      &lt;thead class=&quot;thead-dark&quot;&gt;
          &lt;tr&gt;
              &lt;th scope=&quot;col&quot;&gt;TYPE&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;CREATE&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;VIEW&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;UPDATE&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;DELETE&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      @foreach($permissions as $permission)
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div class=&quot;custom-control custom-checkbox ml-3&quot;&gt;
                      &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; id=&quot;{{ $permission-&gt;name }}&quot; value=&quot;{{ ($permission-&gt;name) }}&quot; {{ ($permission-&gt;name == &quot;$role-&gt;permissions-&gt;name&quot;) ? &quot;checked&quot; : &quot;&quot; }}&gt;
                      &lt;label class=&quot;custom-control-label&quot; for=&quot;{{ $permission-&gt;name }}&quot;&gt;{{ $permission-&gt;display_name }}&lt;/label&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      @endforeach
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>I'm not getting any errors but I cant make the checkbox to be checked if they match... I'm using Laratrust 5.2</p>