Route.php第639行中的UnexpectedValueException:无效的路由操作:[App\Http\Controllers\PortfolioController]

Tba*_*tin 3 php laravel

为什么我收到此错误.我创建了一个PortfolioController.然后我用这个做了一条路线

Route::get('portfolio','PortfolioController');  
Run Code Online (Sandbox Code Playgroud)

所以在我的控制器页面中我做了这个.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class PortfolioController extends Controller
{
  //This only gets exectued when we request /portfolio/Paintings using GET
    public function getPaintings()
    {
      return 'This RESTful controller is working!';
    }
}
Run Code Online (Sandbox Code Playgroud)

输入localhost/portfolio/paintings时出现此错误

pat*_*cus 6

从代码的外观来看,您似乎正在尝试设置隐式控制器路由.你很近,但你的路线定义有点偏差.您需要使用controller而不是get:

Route::controller('portfolio','PortfolioController');
Run Code Online (Sandbox Code Playgroud)