2015-11-24 27 views
1

嗨也許我失去了一些東西但是如果我使用諸如Laravel刀模板不會塞在這裏呈現

/管理員用戶管理

然後刀片模板呈現正確的路線。然而,使用確切的代碼,複製/粘貼到另一個視圖與路線

/管理/ {ID}

然後視圖不會呈現模板。

兩種視圖在每一種方式都是相同的,一種是使用模板正確渲染視圖,而另一種使用slug則不會正確渲染模板,它會隨機吐出元素,但不會渲染實際佈局正確。

他們爲什麼會不一樣?這並不是我第一次遇到這個問題,而我只是難以理解,如果一個slu is在網址中或者不在網頁中,會有什麼不同。

再次,兩個文件是相同的。

一個是useraccounts功能,另一個是控制器上的顯示功能。

public function show($id) 
{ 
    $user=User::find($id); 
    return view('admin.show',compact('user')); 
} 

public function useraccounts() 
{ 
    $users = User::all(); 
    return view('admin.useraccounts', compact('users')); 
} 

和顯示用戶的詳細信息按鈕如下

<a href="{{route('admin.show',$user)}}" class="btn btn-primary">View all information</a> 

請有沒有人有這個問題,我有什麼想法?


的admin.show視圖

@extends('admin') 

@section('main') 
    <aside class="right-side"> 
     <!-- Content Header (Page header) --> 
     <section class="content-header"> 
      <h1> 
       Dashboard 
       <small>Control panel</small> 
      </h1> 
      <ol class="breadcrumb"> 
       <li><a href="/admin"><i class="fa fa-dashboard"></i> Home</a></li> 
       <li class="active">Dashboard</li> 
      </ol> 
     </section> 

     <!-- Main content --> 
     <section class="content"> 

      <!-- Small boxes (Stat box) --> 
      <div class="row"> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-green"> 
         <div class="inner"> 
          <h3> 
           {{--53<sup style="font-size: 20px">%</sup>--}} 
          </h3> 
          <p> 
           Statistics 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-stats-bars"></i> 
         </div> 
         <a href="#" class="small-box-footer"> 
          View Information <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-yellow"> 
         <div class="inner"> 
          <h3> 
           {{--53--}} 
          </h3> 
          <p> 
           User Management 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-person-add"></i> 
         </div> 
         <a href="/admin-user-management" class="small-box-footer"> 
          Edit Details <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-red"> 
         <div class="inner"> 
          <h3> 
           {{--65--}} 
          </h3> 
          <p> 
           Detailed Site Information 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-pie-graph"></i> 
         </div> 
         <a href="#" class="small-box-footer"> 
          View Data <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
      </div><!-- /.row --> 

      <!-- top row --> 
      <div class="row"> 
       <div class="col-xs-12 connectedSortable"> 

       </div><!-- /.col --> 
      </div> 

     </section><!-- /.content --> 
     <label>{{$user->name}}</label> 
    </aside><!-- /.right-side --> 
@endsection 

然後其使用

@extends('admin') 

@section('main') 
    <aside class="right-side"> 
     <!-- Content Header (Page header) --> 
     <section class="content-header"> 
      <h1> 
       Dashboard 
       <small>Control panel</small> 
      </h1> 
      <ol class="breadcrumb"> 
       <li><a href="/admin"><i class="fa fa-dashboard"></i> Home</a></li> 
       <li class="active">Dashboard</li> 
      </ol> 
     </section> 

     <!-- Main content --> 
     <section class="content"> 

      <!-- Small boxes (Stat box) --> 
      <div class="row"> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-green"> 
         <div class="inner"> 
          <h3> 
           {{--53<sup style="font-size: 20px">%</sup>--}} 
          </h3> 
          <p> 
           Statistics 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-stats-bars"></i> 
         </div> 
         <a href="#" class="small-box-footer"> 
          View Information <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-yellow"> 
         <div class="inner"> 
          <h3> 
           {{--53--}} 
          </h3> 
          <p> 
           User Management 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-person-add"></i> 
         </div> 
         <a href="#" class="small-box-footer"> 
          Edit Details <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
       <div class="col-lg-3 col-xs-6"> 
        <!-- small box --> 
        <div class="small-box bg-red"> 
         <div class="inner"> 
          <h3> 
           {{--65--}} 
          </h3> 
          <p> 
           Detailed Site Information 
          </p> 
         </div> 
         <div class="icon"> 
          <i class="ion ion-pie-graph"></i> 
         </div> 
         <a href="#" class="small-box-footer"> 
          View Data <i class="fa fa-arrow-circle-right"></i> 
         </a> 
        </div> 
       </div><!-- ./col --> 
      </div><!-- /.row --> 

      <!-- top row --> 
      <div class="row"> 
       <div class="col-xs-12 connectedSortable"> 

       </div><!-- /.col --> 
      </div> 

     </section><!-- /.content --> 
     <div class="container-fluid"> 
      <div class="form-box"> 

       @if (session('message')) 
        <div class="alert alert-info" style="text-align: center; width: 200px; "> 
         {{ session('message') }} 
        </div> 
       @endif 

       <div class="container"> 

        {{-- @if(Auth::user()) --}} 
        <form class="form-group"> 
         @if($users != null) 
          @foreach($users as $user) 
           @if($user->admin != 'true') 
            {!! Form::label($user->name) !!} 
            <div class="container"> 
             <br> 
             <a href="{{route('admin.show', ['id' => $user->id])}}" class="btn btn-primary">View all information</a> 
            </div> 
            </br> 
            <div class="container"> 
             {{-- <a href="{{route('house.edit',$house)}}" class="btn btn-primary">Update house details</a> --}} 
            </div> 
            <br> 

            <div class="container"> 
             {{-- {!! Form::open(['method' => 'DELETE', 'route'=>['house.destroy', $house->id]]) !!} --}} 
             {{-- {!! Form::submit('Delete House', ['class' => 'btn btn-danger']) !!} --}} 
             {{-- {!! Form::close() !!} --}} 
            </div> 
           @endif 
          @endforeach 
         @else 
          {{-- <li><a href={{url('/house/create')}}>Add new house</a></li> --}} 
         @endif 
        </form> 
        {{-- @endif --}} 
       </div> 
      </div> 
     </div> 
    </aside><!-- /.right-side --> 
@endsection 

的routes.php文件文件

//Admin Routes 

Route::get('/admin-user-management', '[email protected]'); 
Route::resource('admin', 'AdminController'); 
的admin.admin用戶管理視圖

標題

<head> 
    <meta charset="UTF-8"> 
    <title>Admin | Dashboard</title> 
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> 
    <!-- bootstrap 3.0.2 --> 
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 
    <!-- font Awesome --> 
    <link href="bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> 
    <!-- Ionicons --> 
    <link href="bootstrap/css/ionicons.min.css" rel="stylesheet" type="text/css" /> 
    <!-- Morris chart --> 
    <link href="bootstrap/css/morris/morris.css" rel="stylesheet" type="text/css" /> 
    <!-- jvectormap --> 
    <link href="bootstrap/css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" /> 
    <!-- fullCalendar --> 
    <link href="bootstrap/css/fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css" /> 
    <!-- Daterange picker --> 
    <link href="bootstrap/css/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" /> 
    <!-- bootstrap wysihtml5 - text editor --> 
    <link href="bootstrap/css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" /> 
    <!-- Theme style --> 
    <link href="bootstrap/css/AdminLTE.css" rel="stylesheet" type="text/css" /> 

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> 
    <![endif]--> 
</head> 
+0

你分享的頭部分,你包含的CSS樣式表 –

+0

我添加的報頭中的信息。但是正如我所說,即使代碼被複制,只有一個正確渲染,而另一個沒有,所以我覺得在一個方式標題信息是無關的,但如果它確實有幫助,那麼我已經添加它:) – Zangpakto

+0

讓我猜測,CSS文件被放置在公共/管理/引導? –

回答

1

你的資產的路徑是相對的,他們應該是絕對的:

<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 

通知bootstrap/css/bootstrap.min.css之前額外/。如果/丟失,並且您的URL爲/admin/1,則相對路徑爲/admin,並且它將嘗試查找/admin/bootstrap/css/bootstrap.min.css中的引導程序CSS文件,該文件當然不存在。


最好的解決方案是產生任何資產的URL時使用的asset輔助函數,因爲它會產生一個完整的URL包括協議和域,這將避免任何此類問題在未來,像這樣:

<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" /> 

asset函數將生成的URL像這樣:

http://example.com/bootstrap/css/bootstrap.min.css 

這將意味着該位置將永遠是正確。當然,您應該在從服務器加載所有資產(包括JavaScript文件)時使用該功能,但不應使用從maxcdn.com加載的外部資源html5shiv

+0

嗨,如果我用數據轉儲似乎無論哪種方式,吐出來的是正確的信息,所以那不是僅僅是因爲使用 View all information Zangpakto

+0

也許我誤解你的問題,以達到相同的結果的另一種方式,你說, 'admin.show'視圖渲染不正確?如果是這樣,請包含查看代碼。 – Bogdan

+0

我沒有任何問題檢索實際數據本身,但是當我嘗試渲染視圖時,它只能在沒有slu works的情況下運行。一旦添加了slu the,模板根本不會渲染。 – Zangpakto