Q:

laravel 5.4 - comparing user input to db value

I have utilized laravel's make:auth and was playing around with the registration part. I am trying to compare the user's input to the values that I already have in my database, if it exist then the user would proceed to the registration and if doesn't, it would take the user to another page. Now, after executing the function, it would directly take the user to another page. What seems to be the problem?
public function register(Request $request)
{
    $name = $request->name;
    $lastname = $request->lastname;
    $check = DB::table('records')->where([
        ['firstname','=',$name],
        ['lastname','=',$lastname]
        ])->get();
    if ($check===null) {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
                        ?: redirect($this->redirectPath());
    } else {
        return redirect('/');
    }

}

A:

get() method returns an collection, so if there is no record $check would be similar to
$a = collect([]);

and
$a === null // returns false
$a->isEmpty(); // returns true
count($a); // returns 0

so you might want to use a different comparison in your if clause and this would be

if it exist then the user would proceed to the registration

if (!$check->isEmpty()) {
    // proceed to registration
} else {
    // redirect
}

