title: Whats the difference between @if and @can in laravel
body: <p>Were making a project with different users. I noticed that I can use <code>@if</code> to prevent specific user from a specific function but I can also use <code>@can</code>. Can someone tell me what are thier differences. I did not register any policies in <code>AuthServiceProvider</code> but I can still use <code>@can</code> method. I'm just referring to the type of user.  I'll show you some code.</p>
  
  <p>Can</p>
  
  <pre><code>   @can($global_user-&gt;role != 0)
              &lt;li class="{{ $mnuname == 'Issue' ? 'active' : '' }}"&gt;
                &lt;a href="{{ route('admin.issues') }}" onclick="return LoadingOverlay();"&gt;
                  &lt;i class="fa fa-list"&gt;&lt;/i&gt;
                  &lt;span&gt;Issue Tracker&lt;/span&gt;
                &lt;/a&gt;
              &lt;/li&gt;
    @endcan
  </code></pre>
  
  <p>If</p>
  
  <pre><code>   @if($global_user-&gt;role != 0)
  
          &lt;li class="{{ $mnuname == 'Student' ? 'active' : '' }}"&gt;
            &lt;a href="{{ route('admin.students') }}" onclick="return LoadingOverlay();"&gt;
              &lt;i class="fa fa-child"&gt;&lt;/i&gt;
              &lt;span&gt;Students&lt;/span&gt;
            &lt;/a&gt;
          &lt;/li&gt;
  @endif
  </code></pre>
  
  <p>Edit: Can I also use <code>@can</code> inside <code>@if</code> statements like this?</p>
  
  <pre><code>    @if($global_user-&gt;role != 0)
          &lt;li class="treeview
              {{ $mnuname == 'New Issue' ? 'active' : '' }}
              {{ $mnuname == 'Issue' ? 'active' : '' }}
              "&gt;
            &lt;a href="#"&gt;
              &lt;i class="fa fa-bug"&gt;&lt;/i&gt; &lt;span&gt;System Issues&lt;/span&gt;
              &lt;span class="pull-right-container"&gt;
                &lt;i class="fa fa-angle-left pull-right"&gt;&lt;/i&gt;
              &lt;/span&gt;
            &lt;/a&gt;
            &lt;ul class="treeview-menu"&gt;
  
              &lt;li class="{{ $mnuname == 'New Issue' ? 'active' : '' }}"&gt;
                &lt;a href="{{ route('admin.issues.create') }}" onclick="return LoadingOverlay();"&gt;
                  &lt;i class="fa fa-edit"&gt;&lt;/i&gt;
                  &lt;span&gt;Report an Issue&lt;/span&gt;
                &lt;/a&gt;
              &lt;/li&gt;
  
  
              @can($global_user-&gt;role != 3)
              &lt;li class="{{ $mnuname == 'Issue' ? 'active' : '' }}"&gt;
                &lt;a href="{{ route('admin.issues') }}" onclick="return LoadingOverlay();"&gt;
                  &lt;i class="fa fa-list"&gt;&lt;/i&gt;
                  &lt;span&gt;Issue Tracker&lt;/span&gt;
                &lt;/a&gt;
              &lt;/li&gt;
              @endcan
  
  
            &lt;/ul&gt;
          &lt;/li&gt;
          @endif
  </code></pre>