0
votes

I have been trying to get a simple example to work but it keeps giving me Route [login] not defined when I try to load the page. I have tried to test each part individually with no luck; what could be the issue here?

My code is as follows:

Class:Users.php

  class users extends Model
{
   public $table = 'users';
}

Controller:UserController.php

use App\users;
public function index()
{
    return "Hello Laravel";

}

Route:

Route::get('/user','UserController@index');
5
u r having only createUser route, but why u are accessing login route - arun
Run php artisan route:list to see if route is defined - Mahdi Younesi
Have you defined the login route?? - Sunny Kumar
I am not trying to access login at all if you read my code you will see that I am only trying to save data to a database at this point but the page does not load gives login not defined while i am not using login in my code? - Jelly Bean
@It is all yours, it seems that the route is not being defined what could be the cause of this? - Jelly Bean

5 Answers

2
votes

clear route cache:

php artisan route:cache

after that you can check your routes to be sure:

php artisan route:list

Remember - apparently you cannot use route caching if you have ANY route closures. Make a controller and use your logic there and direct your route to the Controller/Method.

Proper route defining example :

Route::get('/user', 'UserController@index');
0
votes

try this Auth::routes(); before your code

Route::get('/user','UserController@index');
0
votes

There was an issue with the controller itself still unsure as to what the issue was but deleting and recreating the controller seems to have solved the issue.

0
votes

see if the route is defined in web.php and if it has a name like this

Route::get('/example', 'ExampleController@index')->name('example');

in your view you can use the helper route('example');

0
votes

From the documentation:

Just run php artisan make:auth and php artisan migrate in a fresh Laravel application. Then, navigate your browser to http://your-app.test/register or any other URL that is assigned to your application. These two commands will take care of scaffolding your entire authentication system!