方法App \ Http \ Controllers \ ProductController :: getIndex()()不存在

时间:2017-03-11 07:17:52

标签: laravel laravel-5 laravel-routing laravel-5.4

web.php文件

这是我使用laravel 5.4的web.php文件

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', [

            'uses' =>'ProductController@getIndex()',
            'as' =>'product.index'

    ]);

ProductController.php

这是我使用laravel5.4的控制器文件

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ProductController extends Controller
{
    //



    public function getIndex(){
        return view('shop.index');
    }
}

如何摆脱这个错误请帮助我。

它有什么问题?

1 个答案:

答案 0 :(得分:2)

您不应在路线定义中使用()。它应该是:

Route::get('/', [

            'uses' =>'ProductController@getIndex',
            'as' =>'product.index'

    ]);