doujiao3998 2015-10-06 12:53
浏览 100
已采纳

资源路由返回空白页面

I'm trying to create a resource controller (for CRUD) in Laravel 5.1. I added this to the 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');

This is my controller: http://pastebin.com/mcm6kfSB

This is my view:

@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>

When I go to http://partyrecycler.dev/markers/index I get a blank page with no content and I don't know why, help?

  • 写回答

1条回答 默认 最新

  • dotj6816 2015-10-06 13:11
    关注

    Your url shouldn't have the /index appended. Route::resource() automatically creates the routes for you. Try typing php artisan route:list from the command line and you should get all your application routes, including the ones created by Route::resource.

    So, in your case, resource is essentially doing:

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

    and you access it as:

    http://yourdomain.com/markers

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout
  • ¥15 Android studio AVD启动不了