laravel 在 RouteAction.php 第 84 行:无效的路由操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50095242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:41:37  来源:igfitidea点击:

In RouteAction.php line 84: Invalid route action

laravel

提问by Norlihazmey Ghazali

When I create a controller in laravel 5.4 I get this error

当我在 laravel 5.4 中创建控制器时出现此错误

In RouteAction.php line 84:

Invalid route action: [App\Http\Controllers\Admin\DashboardController].

在 RouteAction.php 第 84 行:

无效的路由操作:[App\Http\Controllers\Admin\DashboardController]。

I do not create Admin/DashboardController. Still makes a errors

我不创建 Admin/DashboardController。还是会报错

web.php

网页.php

Route::group(['namespace' => 'Admin', 'middleware' => ['auth:web', 'CheckAdmin'], 'prefix' => 'admin'],function (){
    $this->resource('authorities', 'AuthoritiesController');
    $this->resource('complaints', 'ComplaintsController');
    $this->resource('schools-list', 'SchoolsListController');
    $this->resource('inspection-failed', 'InspectionFailedController');
    $this->resource('inspection-register', 'InspectionRegisterController');
    $this->resource('inspection-results', 'InspectionResultsController');
    $this->resource('inspectors-list', 'InspectionListController');
    $this->resource('investigators', 'InvestigatorsController');
    $this->resource('notification-infringement', 'NotificationInfringementController');
    $this->resource('system-experts', 'SystemExpertsController');
    $this->resource('submit-information', 'SubmitInformationController');
    $this->resource('primary-committee-meeting', 'PrimaryCommitteeMeetingController');
    $this->resource('list-violations-school', 'ListViolationsSchoolController');
    $this->resource('announcing', 'AnnouncingController');
    $this->resource('display-vote', 'DisplayVoteController');
    $this->resource('announcing-supervisory-vote', 'AnnouncingSupervisoryVoteController');
    $this->resource('supervisory-board-vote', 'SupervisoryBoardVoteController');
    $this->resource('defense', 'DefenseController');
    $this->resource('votiing-supervisory-board', 'VotiingSupervisoryBoardController');
    $this->get('dashboard', 'DashboardController');
});

回答by Norlihazmey Ghazali

Because it is invalid. As you're using GETroute, you must specify method name(unless you used ::resource):

因为它是无效的。当您使用GET路由时,您必须指定方法名称(除非您使用了::resource):

$this->get('dashboard', 'DashboardController@methodName');

回答by Kazi Rabbi Hassan

I also face a similar problem:

我也面临类似的问题:

<?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('/', 'Frontend\FrontendController@index')->name('home');
Route::get('/post', 'Frontend\FrontendController@post')->name('post');
Route::get('/contact', 'Frontend\FrontendController@contact')->name('contact_us');
Route::group(['prefix' => 'admin'], function () {

    Route::get('/create', 'Backend\BackendController@index');

    //User Route

    Route::get('/registration', '');
});

And I just remove the Route::get('/registration', '');and it's work for me :)

我只是删除了Route::get('/registration', '');它,它对我有用:)

回答by Mohiuddin

Those who are new to Laravel or learning use

Laravel 新手或学习使用者

Route::resource('resource_name','controller_name')

to avoid this kind of error when you type:

为避免键入时出现此类错误:

php artisan route:list

In cmd or any other command line.

在 cmd 或任何其他命令行中。