2015-10-06 74 views
1

我試圖在Laravel 5.1中創建一個資源控制器(for CRUD)。我已將此添加到應用程序/ HTTP/routes.php文件:資源路由返回空白頁

<?php 

Route::get('/', function() { 
    return view('home'); 
}); 

Route::get('/home', function() { 
    return view('home'); 
}); 

Route::resource('markers', 'MarkerController'); 

Route::get('auth/login', 'Auth\[email protected]'); 
Route::post('auth/login', 'Auth\[email protected]'); 
Route::get('auth/logout', 'Auth\[email protected]'); 

Route::get('auth/register', 'Auth\[email protected]'); 
Route::post('auth/register', 'Auth\[email protected]'); 

這是我的控制器:http://pastebin.com/mcm6kfSB

這是我的看法:

@if (Session::has('message')) 
    <div class="alert alert-info">{{ Session::get('message') }}</div> 
@endif 

<table class="table table-striped table-bordered"> 
    <thead> 
     <tr> 
      <td>Name</td> 
      <td>x</td> 
      <td>y</td> 
      <td>Actions</td> 
     </tr> 
    </thead> 
    <tbody> 
    @foreach($markers as $key => $value) 
     <tr> 
      <td>{{ $value->name }}</td> 
      <td>{{ $value->x }}</td> 
      <td>{{ $value->y }}</td> 

      <td> 
       <a href="markers/index">Show</a> 
       <a href="markers/idnex">Edit</a> 
      </td> 
     </tr> 
    @endforeach 
    </tbody> 
</table> 

當我去http://partyrecycler.dev/markers/index我得到一個沒有內容的空白頁面,我不知道爲什麼,幫助?

回答

0

您的網址不應該附加/ index。 Route::resource()會自動爲您創建路線。嘗試從命令行輸入php artisan route:list,您應該獲得所有應用程序路由,包括由Route::resource創建的路徑。

所以,在你的情況下,資源基本上是這樣做的:

Route::get('/markers', '[email protected]')

,你訪問它:

http://yourdomain.com/markers

+0

這工作,謝謝! – Alexander