10
votes

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

In RouteAction.php line 84:

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

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

web.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');
});
6
I am sure you just don't want $this->get('dashboard', 'DashboardController');Niklesh Raut

6 Answers

28
votes

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

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

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 :)

2
votes

Those who are new to Laravel or learning use

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.

2
votes

try removes route cache file by

php artisan route:clear

2
votes

If you are using laravel 8 you need to add your controller and method name inside the array, otherwise, it will throw an error.

Route::get('/projects', User\ProjectController::class, 'index')->name('user.projects');

TO

 Route::get('/projects', [User\ProjectController::class, 'index'])->name('user.projects');
1
votes

I hit the same issue but with a different cause. So I'm documenting here just in case someone else hits the same cause.

Specifically if you are using a Single Action Controller (ie: with __invoke), if you haven't added or omitted the correct use Laravel will hide the missing controller with "Invalid route action: [XController]."

This will fail

<?php
use Illuminate\Support\Facades\Route;

Route::post('/order', XController::class);

This will pass

<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\XController;

Route::post('/order', XController::class);

I think its a bit unfortunate that Laravel masks the underlying issue, but I think it only applies to invokable controllers, even though its a silly mistake on my behalf.