-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.x] Add column name customisation options for Auth used with database provider #51162
[11.x] Add column name customisation options for Auth used with database provider #51162
Conversation
Config values now pass through CreatesUserProviders.php and DatabaseUserProvider.php
Updated the pr to pass the config to the GenericUser via the 'right' way. Not realy sure where the default values should be defined, but I did it in the GenericUser class. Setting a default is necessary for backwards compatibility, because this update is depending on a change in the auth.php config. If it should be done different, let me know. /**
* Create a new generic User object.
*
* @param array $attributes
* @param array|null $columns
* @return void
*/
public function __construct(array $attributes, array $columns = null)
{
$this->attributes = $attributes;
$this->columns = $columns ?? [
'primary_key' => 'id',
'password' => 'password',
'remember_token' => 'remember_token',
];
} |
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions! If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response. |
@devfrey Can you elaborate on your feedback? I feel like the database auth provider is lacking customisation, even if it isn't used as much as the eloquent method. Is there a better way to implement it, or do you think column name customisation just doesn't add enough value? |
@Daniel-H123 The user providers can already be customized or extended. Simply implement |
I see. I agree that it makes the implementation more complicated. Thanks for explaining. |
This pull request will add:
This pr will add the option to customise column names, in the users table when using the Auth login functions in combination with the database driver. Column name customisation is also possible when eloquent is used (by overriding the getter functions in the users model, but there is no way to do it when the database provider is used.
How to use:
Users can customise the column names by editing the providers config. My first thought was to add a new 'database' key, that is commented out by default, but since 'table' is already located in providers, it seems best to place it there.
By default, the eloquent provider is used, but when the database provider is used, you can easily replace the column names in the config.