title: Laravel 4 blade views
body: <p>In my view there is an if function like this:</p>
  
  <pre><code>@if ( Auth::guest() )
  
  &lt;li style="float: right;padding-right: 0"&gt;
    &lt;ul class="nav"&gt;
      &lt;li&gt;
        &lt;a href="{{ URL::to('register') }}"&gt;
          &lt;i class="icon-black icon-plus"&gt;
          &lt;/i&gt;
  
          &lt;strong&gt;
            Register
          &lt;/strong&gt;
        &lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href="{{ URL::to('login') }}"&gt;
          &lt;i class="icon-black icon-lock"&gt;
          &lt;/i&gt;
  
          &lt;strong&gt;
            Log in
          &lt;/strong&gt;
        &lt;/a&gt;
      &lt;/li&gt;
    &lt;/li&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  
  @else
  
  &lt;li class="divider-vertical"&gt;
  &lt;/li&gt;
  &lt;li style="float: right;padding-right: 0"&gt;
  &lt;div class="btn-group"&gt;
    &lt;div class="btn btn-primary"&gt;
      &lt;i class="icon-user"&gt;
      &lt;/i&gt;
      {{ (Auth::user()-&gt;name) }}
    &lt;/div&gt;
  
    &lt;a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"&gt;
      &lt;span class="icon-caret-down"&gt;
      &lt;/span&gt;
    &lt;/a&gt;
  
    &lt;ul class="dropdown-menu"&gt;
      &lt;li&gt;
  
        &lt;a href="{{ URL::to('account/managment') }}"&gt;
          &lt;i class="icon-user"&gt;
          &lt;/i&gt;
          Account Managment  
        &lt;/a&gt;
  
      &lt;/li&gt;
      &lt;li&gt;
  
        &lt;a href="{{ URL::to('account/managment/change_credentials') }}"&gt;
          &lt;i class="icon-lock"&gt;
          &lt;/i&gt;
          Change Password
        &lt;/a&gt;
  
      &lt;/li&gt;
      &lt;li class="divider"&gt;
      &lt;/li&gt;
      &lt;li&gt;
  
        &lt;a href="{{ URL::to('account/logout') }}"&gt;
          &lt;i class="icon-off"&gt;
          &lt;/i&gt;
          Log out
        &lt;/a&gt;
  
      &lt;/li&gt;
  
    &lt;/ul&gt;
  &lt;/div&gt;
  
  @endif
  </code></pre>
  
  <p>Basically if the viewer is a guest, it'll display the specific data, else otherwise. I'm asking you, you see there is an:</p>
  
  <pre><code>@if (Auth::guest())
  </code></pre>
  
  <p>So, could I use something similar from my model? </p>
  
  <p>Role.php</p>
  
  <pre><code>&lt;?php
  
  class Role extends Eloquent {
  
      public function user()
      {
          return $this-&gt;belongsToMany('User');
      }
  
  }
  </code></pre>
  
  <p>and the controller:</p>
  
  <pre><code>&lt;?php
  
  class RoleController extends BaseController {
  
      public function get_role() {
  $roles = Auth::user()-&gt;type;
  
              if ($roles == '5')
               {
                 return View::make('admin.dash');
               } else {
  
                 return Redirect::to('news/index')-&gt;with('danger', 'You either have insufficient permissions to access this page or your user credentials are not refreshed.');
                      }
               }
  }
  </code></pre>
  
  <p>Is it possible to do like <code>if($roles == 5)</code> or something like that in the view?</p>