title: "Undefined index: password" Laravel 8.61.0
body: <p>I just checked using <code>dd()</code> that my variable <code>$username</code> and <code>$password</code> are not null.
  But why <code>Auth::attempt($user)</code> is always return error message <code>Undefined index: password</code></p>
  <p><strong>LoginController.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  
  class LoginController extends Controller
  {
      public function index()
      {
          return view('login/index', [
              'title' =&gt; 'LOGIN'
          ]);
      }
  
      public function authenticate(Request $request)
      {
          $hashed_password = hash(config('var.default_hash'), $request['password']);
          $request['password'] = $hashed_password;
  
          $request-&gt;validate([
              'username' =&gt; ['required'],
              'password' =&gt; ['required'],
          ]);
  
          $user = [
              'username' =&gt; $request['username'],
              'password_hash' =&gt; $request['password']
          ];
  
          if (Auth::attempt($user)) {
              $request-&gt;session()-&gt;regenerate();
              return redirect()-&gt;intended('/');
          }
  
          return back()-&gt;with('fail', 'Login fail');
      }
  }
  </code></pre>
  <p><strong>User.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Contracts\Auth\Authenticatable;
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  
  class User extends Model implements Authenticatable
  {
      use HasFactory;
      public $timestamps = false;
      protected $fillable = ['name', 'username', 'password_hash', 'lang'];
  
      /**
       * The column name of the &quot;remember me&quot; token.
       *
       * @var string
       */
      protected $rememberTokenName = 'remember_token';
  
      /**
       * Get the name of the unique identifier for the user.
       *
       * @return string
       */
      public function getAuthIdentifierName()
      {
          return $this-&gt;getKeyName();
      }
  
      /**
       * Get the unique identifier for the user.
       *
       * @return mixed
       */
      public function getAuthIdentifier()
      {
          return $this-&gt;{$this-&gt;getAuthIdentifierName()};
      }
  
      /**
       * Get the unique broadcast identifier for the user.
       *
       * @return mixed
       */
      public function getAuthIdentifierForBroadcasting()
      {
          return $this-&gt;getAuthIdentifier();
      }
  
      /**
       * Get the password for the user.
       *
       * @return string
       */
      public function getAuthPassword()
      {
          return $this-&gt;password_hash;
      }
  
      /**
       * Get the token value for the &quot;remember me&quot; session.
       *
       * @return string|null
       */
      public function getRememberToken()
      {
          if (!empty($this-&gt;getRememberTokenName())) {
              return (string) $this-&gt;{$this-&gt;getRememberTokenName()};
          }
      }
  
      /**
       * Set the token value for the &quot;remember me&quot; session.
       *
       * @param  string  $value
       * @return void
       */
      public function setRememberToken($value)
      {
          if (!empty($this-&gt;getRememberTokenName())) {
              $this-&gt;{$this-&gt;getRememberTokenName()} = $value;
          }
      }
  
      /**
       * Get the column name for the &quot;remember me&quot; token.
       *
       * @return string
       */
      public function getRememberTokenName()
      {
          return $this-&gt;rememberTokenName;
      }
  }
  </code></pre>
  <p><strong>2021_09_24_081907_create_users_table.php</strong></p>
  <pre><code>&lt;?php
  
  use Illuminate\Database\Migrations\Migration;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Support\Facades\Schema;
  
  class CreateUsersTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('users', function (Blueprint $table) {
              $table-&gt;id();
              $table-&gt;string('name');
              $table-&gt;string('username');
              $table-&gt;text('password_hash');
              $table-&gt;String('lang');
              $table-&gt;timestamp('created_at')-&gt;useCurrent();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('users');
      }
  }
  </code></pre>