Aamir khan
Aamir khan

Reputation: 103

BadMethodCallException in Macroable.php line 74 : Method controller does not exist

I'm getting little bit issue when I follow Route Controller.

Web.php Code:

{"
Route::controller('/admin','adminController');
"}

adminController.php Code:

{"
<?php
namespace App\Http\Controllers;
class adminController extends Controller{
public function getDashboard(){
echo " Get Dashborad Method ";
}}
"}

When I hit http://localhost:8000/admin/dashboard an error:

Display ("BadMethodCallException in Macroable.php line 74 : Method controller does not exist.")

Here is SnapShot:

http://take.ms/3NqA4

Please take a look and let me know what is wrong with code.

Upvotes: 9

Views: 20830

Answers (4)

Serhiy Zaharchenko
Serhiy Zaharchenko

Reputation: 1760

Faced the same problem recently. Laravel 5.3 does not support Route::controller() method. You need to change it to Route::get(). Please check how to use it here https://laravel.com/docs/5.3/routing#basic-routing.

Upvotes: 10

Mohsin G
Mohsin G

Reputation: 41

i have just solved this problem i was using

$table->int('TeachingGroup_id');

where i should use the full integer Not int only by solving this now migration done S

Upvotes: 0

Dhanushka Udayanga
Dhanushka Udayanga

Reputation: 781

I got this error while running artisan command. Finally, I solve by removing the,

use Illuminate\Routing\Route

in web.php file.

Upvotes: 3

Mohamed Salem Lamiri
Mohamed Salem Lamiri

Reputation: 6077

Please also make sure you don't use any namespace inside your routes file.

E.g. If by mistake your IDE add's

use Illuminate\Routing\Route;

It could result in the same error mentioned above. Your route file (web.php or api.php) should not use the Illuminate\Routing\Route class.

EDIT: Tested on Laravel 5.5

Upvotes: 11

Related Questions