B
B
blackVirus2022-03-05 14:02:39
Laravel
blackVirus, 2022-03-05 14:02:39

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'hidi. users' doesn't exist?

Everything seems to be OK in the database, the fields are correctly written in the tables too. When I try to register for the lesson https://www.youtube.com/watch?v=prl9r8nBJ5w&t=225s , I get this error. And in the sql query, the spaces before the name of the table and field came from somewhere.
62234301106ce184534848.png
Here is the controller code:

class RegisterController extends Controller
{
    public function save(Request $request){
        if (Auth::check()){
            return redirect(route('Authentication'));
        }

        $validateFields = $request->validate([
            'Name' => 'required|string',
            'Surname' => 'string',
            'Patronymic' => 'string',
            'Login' => 'required|string|unique: users, Login',
            'Password' => 'required|confirmed',
        ]);

        $user = User::create($validateFields);
        if ($user){
            Auth::login($user);
            return redirect(route('Account'));
        }
        return redirect(route('Main'))->withErrors([
            'formError' => 'Произошла ошибка при регистрации!',
        ]);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2022-03-05
@blackVirus

'Login' => 'required|string|unique: users, Login',

There should be no spaces here
'Login' => 'required|string|unique:users,Login',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question