ilya bogackiy
ilya bogackiy

Reputation: 51

(1/1) BadMethodCallException in Laravel 5.4

I've set up a simple controller, route and a view in my new installation of Laravel 5.4.

Here's my web.php:

<?php
use App\Task;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return view('welcome');
});

Route::get('profile', 'UserController@profile');

My UserController.php:

<?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;

class UserController extends Controller
{

    public function profile()
    {
        return view('profile'); 
    }

}

My view file is profile.blade.php and there is one string only "Hello world!"

When trying to access: .../profile i get

(1/1) BadMethodCallException
Method [profile] does not exist.
in Controller.php (line 82)
at Controller->__call('profile', array())
at UserController->profile()
at call_user_func_array(array(object(UserController), 'profile'), array())
in Controller.php (line 55)

What am I doing wrong? Please help me to understand

Upvotes: 1

Views: 2580

Answers (1)

Leo
Leo

Reputation: 7420

It seems that route can not find the controller.Or project files are messed up.

Go ahead and delete the controller.Then run composer dump-autoload

Then run the command on command line php artisan make:controller UserController then paste profile method that u have.

Upvotes: 1

Related Questions