0
votes

I was trying to register user using the Laravel Auth. First I got error with App\User not found then I fix it with App\Models\User it works. I don't really know what with Laravel 8 becuase I never had a problem with user registration with previous version. Then I got this problem

BadMethodCallException Method App\Http\Controllers\HomeController::home does not exist.

I don't really know which code to provide since I don't even touch the default code of the Authentication/HomeController.

But I did changed the namespace in RouteProvider

protected $namespace = 'App\Http\Controllers';

web.php

Route::get('/home', [HomeController::class,'home']);
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('home');
    }
}



enter image description here

2
You are calling home method from route in home controller. Only index method exist in your home controller. Firt create home method it will solve your problem. - Irshad Khan
thank you for pointing that out! I definitely miss the index method. Thank you - lily
Is it your answer? - Irshad Khan

2 Answers

1
votes

Try Route::get('/home', [HomeController::class,'index']);

1
votes

in your web.php top you need to import

use App\Http\Controllers\HomeController;

then u can use

Route::get('/home', [HomeController::class,'index']);

Or else

Route::get('/home', 'HomeController@index')->name('home');

use this here no need to import

Note - your error is showing u don't have home method in your controller so create home method or change the correct method by default it is index