2013-08-02 7 views
0

이있는 같은 기능을하는 경우 : 시청자가 게스트 인 경우Laravel 4 블레이드 전망을 내보기에서

@if (Auth::guest()) 

<li style="float: right;padding-right: 0"> 
    <ul class="nav"> 
    <li> 
     <a href="{{ URL::to('register') }}"> 
     <i class="icon-black icon-plus"> 
     </i> 

     <strong> 
      Register 
     </strong> 
     </a> 
    </li> 
    <li> 
     <a href="{{ URL::to('login') }}"> 
     <i class="icon-black icon-lock"> 
     </i> 

     <strong> 
      Log in 
     </strong> 
     </a> 
    </li> 
    </li> 
</li> 
</ul> 

@else 

<li class="divider-vertical"> 
</li> 
<li style="float: right;padding-right: 0"> 
<div class="btn-group"> 
    <div class="btn btn-primary"> 
    <i class="icon-user"> 
    </i> 
    {{ (Auth::user()->name) }} 
    </div> 

    <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"> 
    <span class="icon-caret-down"> 
    </span> 
    </a> 

    <ul class="dropdown-menu"> 
    <li> 

     <a href="{{ URL::to('account/managment') }}"> 
     <i class="icon-user"> 
     </i> 
     Account Managment 
     </a> 

    </li> 
    <li> 

     <a href="{{ URL::to('account/managment/change_credentials') }}"> 
     <i class="icon-lock"> 
     </i> 
     Change Password 
     </a> 

    </li> 
    <li class="divider"> 
    </li> 
    <li> 

     <a href="{{ URL::to('account/logout') }}"> 
     <i class="icon-off"> 
     </i> 
     Log out 
     </a> 

    </li> 

    </ul> 
</div> 

@endif 

기본적으로, 다른 그렇지 않으면 특정 데이터를 표시 할 수 있습니다. 내 모델에서 비슷한 사용할 수 있습니다, 그래서

@if (Auth::guest()) 

: 나는 당신을 부탁 해요, 당신은이 보이지?

Role.php

<?php 

class Role extends Eloquent { 

    public function user() 
    { 
     return $this->belongsToMany('User'); 
    } 

} 

및 컨트롤러 :

<?php 

class RoleController extends BaseController { 

    public function get_role() { 
$roles = Auth::user()->type; 

      if ($roles == '5') 
      { 
       return View::make('admin.dash'); 
      } else { 

       return Redirect::to('news/index')->with('danger', 'You either have insufficient permissions to access this page or your user credentials are not refreshed.'); 
        } 
      } 
} 

가보기에 그런 if($roles == 5) 또는 무언가 같이 할 수 있습니까?

답변

1

변경

return View::make('admin.dash'); 

return View::make('admin.dash')->with('roles', $roles); 
+0

작동하지만,에 내 뉴스 페이지로 이동 (또는 인덱스, E/W도 BTW 내가 기본/마스터 레이아웃을 포함)하는 경우 : http://3.imgland.net/0iAN5Z.png 모든 사이트에 있기를 원하지만 admin.dash에서보기를 반환하고 싶습니다. – dinomuharemagic

관련 문제