【问题标题】:Laravel: controller resource index does not return view or stringLaravel:控制器资源索引不返回视图或字符串
【发布时间】:2020-08-24 09:26:27
【问题描述】:

我使用以下方法创建了一个控制器:

php artisan make:controller VideoCategoryController --resource

路线如下:

Route::resource('/admin/video/category', 'VideoCategoryController');

index() 不返回数据,但其他方法正常工作。

public function index()
{ 
    return 'test'; 
}

【问题讨论】:

  • 向我们展示您是如何访问路线的

标签: laravel laravel-resource


【解决方案1】:

函数名应该是:

getIndex() 而不是index()

请参考: https://laravel.com/docs/5.1/controllers#implicit-controllers

【讨论】:

    猜你喜欢
    • 2021-03-08
    • 2014-10-22
    • 1970-01-01
    • 2015-10-15
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多