0

I am trying to register an user using Laravel's native auth. Login works fine, but when I try to register a new user I get an error after submitting a form:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_db.user' doesn't exist

Of course, I made a table named users which I think has more sense and never had trouble up until now.

I am using Entrust for roles and permissions, so I had to change auth.php to:

'providers' => [
    'user' => [
        'driver' => 'eloquent',
        'model' => User::class,
    ],

but even if I make this:

'providers' => [
    'user' => [
        'driver' => 'eloquent',
        'model' => User::class,
        'table' => users
    ],

it submits a form on user table

7
  • 1
    Did you run the migrations? The users table is in the migrations provided by Laravel. Commented Jun 28, 2017 at 16:22
  • users and password_reset tables are already there in migration you have to run migrations Commented Jun 28, 2017 at 16:23
  • I told you I can log in...I couldn't log in if I hadn't ran the migrations first Commented Jun 28, 2017 at 16:25
  • @Norgul Can you check your App\User file? make sure that it has protected $table = "users"; Commented Jun 28, 2017 at 16:29
  • 2
    according to the error, the query attempts inserting into 'my_db.user' while your table is probably named users maybe in your model or config, you forgot writing the s Commented Jun 28, 2017 at 19:33

1 Answer 1

1

First make sure you have properly created your model at User.php and correctly linked your user table. For example protected $table = 'user';

Then make sure to change validator function in the RegisterController.php.

Note: I think you getting error while validating inputs, not submitting to database. Because it checks already registered users(uniqueness) on the database, before adding to it. So, carefully check your email validation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.