title: laravel 5.4 - comparing user input to db value
body: <p>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?</p>
  
  <pre><code>public function register(Request $request)
  {
      $name = $request-&gt;name;
      $lastname = $request-&gt;lastname;
      $check = DB::table('records')-&gt;where([
          ['firstname','=',$name],
          ['lastname','=',$lastname]
          ])-&gt;get();
      if ($check===null) {
          $this-&gt;validator($request-&gt;all())-&gt;validate();
  
          event(new Registered($user = $this-&gt;create($request-&gt;all())));
  
          $this-&gt;guard()-&gt;login($user);
  
          return $this-&gt;registered($request, $user)
                          ?: redirect($this-&gt;redirectPath());
      } else {
          return redirect('/');
      }
  
  }
  </code></pre>