title: Laravel Login and Register Validation
body: <p>Hi thank you for stopping by i'm very new to this framework and assigned to help a fellow to develop login and register.</p>
  
  <p>ok here's my problem i have 2 major issues with laravel 1st login and 2nd register validation.</p>
  
  <p>so i got this laravel program that already includes template for their view and only need to work for login and register part but, for the login and register i do realize it is the same flow (in controller at least as the laravel already provided but for somehow it doesn't work ).</p>
  
  <p>ok let me <strong>show my code 1st for the login part</strong></p>
  
  <p>here's view of my login</p>
  
  <pre><code>             &lt;div class="card-body"&gt;
                                      &lt;form method="POST" action="{{ route('login') }}"&gt;
                                      @csrf
                                      &lt;!-- @csrf_field --&gt;
                                          &lt;div class="form-head"&gt;
                                              &lt;!-- &lt;a href="{{url('/')}}" class="logo"&gt;&lt;img src="assets/images/logo_tmu.jpeg" class="img-fluid" alt="logo"&gt;&lt;/a&gt; --&gt;
                                              &lt;img src="assets/images/logo_tmu.jpeg" class="img-fluid" alt="logo"&gt;
  
                                          &lt;/div&gt;                                        
                                          &lt;h4 class="text-primary my-4"&gt;Log in !&lt;/h4&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" class="form-control" id="username" placeholder="Enter Username here" required&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="password" class="form-control" id="password" placeholder="Enter Password here" required&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-row mb-3"&gt;
                                              &lt;div class="col-sm-6"&gt;
                                                  &lt;div class="custom-control custom-checkbox text-left"&gt;
                                                    &lt;input type="checkbox" class="custom-control-input" id="rememberme"&gt;
                                                    &lt;label class="custom-control-label font-14" for="rememberme"&gt;Remember Me&lt;/label&gt;
                                                  &lt;/div&gt;                                
                                              &lt;/div&gt;
                                              &lt;div class="col-sm-6"&gt;
                                                &lt;div class="forgot-psw"&gt; 
                                                  &lt;a id="forgot-psw" href="{{url('/user-forgotpsw')}}" class="font-14"&gt;Forgot Password?&lt;/a&gt;
                                                &lt;/div&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;                          
                                        &lt;button type="submit" class="btn btn-success btn-lg btn-block font-18"&gt;Log in&lt;/button&gt;
                                      &lt;/form&gt;
                                      &lt;div class="login-or"&gt;
                                          &lt;h6 class="text-muted"&gt;OR&lt;/h6&gt;
                                      &lt;/div&gt;
                                      &lt;!-- &lt;div class="social-login text-center"&gt;
                                          &lt;button type="submit" class="btn btn-primary-rgba font-18"&gt;&lt;i class="mdi mdi-facebook mr-2"&gt;&lt;/i&gt;Facebook&lt;/button&gt;
                                          &lt;button type="submit" class="btn btn-danger-rgba font-18"&gt;&lt;i class="mdi mdi-google mr-2"&gt;&lt;/i&gt;Google&lt;/button&gt;
                                      &lt;/div&gt; --&gt;
                                      &lt;!-- &lt;p class="mb-0 mt-3"&gt;Don't have a account? &lt;a href="{{url('/user-register')}}"&gt;Sign up&lt;/a&gt;&lt;/p&gt; --&gt;
                                  &lt;/div&gt;
  </code></pre>
  
  <p>middleware authenticate</p>
  
  <pre><code>class Authenticate extends Middleware
  {
      /**
       * Get the path the user should be redirected to when they are not authenticated.
       *
       * @param  \Illuminate\Http\Request  $request
       * @return string
       */
      protected function redirectTo($request)
      {
          if (! $request-&gt;expectsJson()) {
              return route('login');
          }
      }
  }
  
  </code></pre>
  
  <p>redirectifauthenticate</p>
  
  <pre><code>class RedirectIfAuthenticated
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @param  string|null  $guard
       * @return mixed
       */
      public function handle($request, Closure $next, $guard = null)
      {
          if (Auth::guard($guard)-&gt;check()) {
              return view('index');
          }
  
          return $next($request);
      }
  }
  
  </code></pre>
  
  <p>at redirect authenticate i decided to render my main page if the login is confirm</p>
  
  <p><strong>my issues here every time i log in and input my email and password even though i already input correctly nothing happens just like the program unable to validate the login.</strong></p>
  
  <p>oke 2nd Register Authentication</p>
  
  <p>so as i explain before the overall flow were mostly the same as the laravel auth that laravel already provided.</p>
  
  <p>here's my register user controller</p>
  
  <pre><code>    protected function validator(array $data)
      {
          return Validator::make($data, [
              'name' =&gt; ['required', 'string', 'max:255'],
              'email' =&gt; ['required', 'string', 'email', 'max:255', 'unique:users'],
              'password' =&gt; ['required', 'string', 'min:8', 'confirmed'],
          ]);
      }
  
      protected function create(Request $request)
      {
  
          $data = [ 'name'=&gt;$request['user'], 'email'=&gt;$request['email'], 'password'=&gt;$request['password']];
  
          validator($data);
  
          return User::create([
              'name' =&gt; $data['name'],
              'email' =&gt; $data['email'],
              'password' =&gt; Hash::make($data['password']),
          ]);
      }
  </code></pre>
  
  <p>if you guys did notice that the structure were little bit different with the standart auth from laravel it is because after testing and trying i did found that i cannot pass array $data in the create function parameter because it is doesn't exist.</p>
  
  <p>so i improvised and create the variable and stated or fill the data as intended to,
  i tried to call the validator function before executing create, but it doesnt work and just pass directly to create somehow the validation does not work.</p>
  
  <p>thank you for stopping by i do hope, you guys can help and please do gives me feedback and input thanks :)</p>