I try to make registration only for people they have a token (a randomly generated key) but I have the Problem that I cant compare my token input with the database.
I tried this:
$token = Tokens::findOrFail($data['register_token']);
if($token) {
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'register_token' => $data['register_token'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'role' => 'student',
]);
}
else {
return redirect('/register')->with('unkown_token', 'This Token does not exist!');
}
I always get an 404 Not found Error. I generated tokens with
$string = str_random(40);