簡體   English   中英

資源路線返回空白頁

[英]Resource Route returns blank page

我正在嘗試在Laravel 5.1中創建一個資源控制器(用於CRUD)。 我將其添加到app / 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\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

這是我的控制器: 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時,我得到了一個空白的頁面,沒有任何內容,我也不知道為什么,幫助嗎?

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

因此,就您而言,資源本質上是在做:

Route::get('/markers', 'MarkerController@index')

您以以下方式訪問它:

http://yourdomain.com/markers

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM