I am very new to Laravel and just started setting up things with Laravel 5. I am attempting to create a simple user authentication app with Laravel.
I created register.blade.php which includes form to register user.
Here is my routes.php
Route::post('/register', function()
{
$user = new User;
$user->email = Input::get('email');
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->save();
$theEmail = Input::get('email');
return View::make('thanks')->with('theEmail', $theEmail);
});
Here is the section of register.blade.php which creates form for the user registration.
{!! Form::open(array('url' => 'register')) !!}
{!! Form::label('email', 'Email Address') !!}
{!! Form::text('email') !!}
{!! Form::label('username', 'Username') !!}
{!! Form::text('username') !!}
{!! Form::label('password', 'Password') !!}
{!! Form::password('password') !!}
{!! Form::submit('Sign Up') !!}
{!! Form::close() !!}
I am getting this error when I click on Sign Up button on register page.
in routes.php line 30 at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Class 'User' not found', 'file' => 'C:\xampp\htdocs\urlshort\app\Http\routes.php', 'line' => '30')) in HandleExceptions.php line 116 at HandleExceptions->handleShutdown()
After going through few queries in Google, I realized I forgot to load the User class. So, I included link to file with User class in composer.json file
"autoload": {
"classmap": [
"database",
"app/User.php"
],
"psr-4": {
"App\\": "app/"
}
},
I ran the composer dump-autoload
command. But I am still getting the same error. I am unable to figure out where my code went work.
try to use
$user = new \App\User;
instead
$user = new User;
I had the same issue, the answer above didn't help, but I used
use App\Models\Access\User\User;
instead of use User;
in my controller and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With