Laravel Framework 5.6.38
I am trying to change the default username auth check from 'email' to 'id', So i put the username() method inside User model file to override the default username method
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password','id' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; public function username() { return 'id'; } } It's not working with me . unless i change it from laravel vendor file Illuminate\Foundation\Auth\AuthenticatesUsers.php
/** * Get the login username to be used by the controller. * * @return string */ public function username() { return 'kocid'; } The login now working but when i run composer update , the file return to it default, so i need a solution to successfully override this method using User model.