[Suggestion] renaming of the users
table
#591
Comments
The idea of the RegisterController is you can override any function you want. So you can just override it and set your own validation rule? |
I do believe this probably makes more sense to have it automatically figure out the users table from the controller stub (for this specific issue) – that said, if you're changing your default table name then I guess it's sort of assumed that you understand more about how this works than your average Joe. How difficult is it to get the users table from the default guard? We could always just:
On that note... I always thought it'd be nice to be able to call something like |
@ConnorVG it's a bit thrown together for my projects, but I've just added your unique suggestion to this rule builder package if your interested in being able to do that. Sorry to highjack the thread with unrelated stuff. |
@timacdonald that is amazing dude – any plans to PR this sort of extension into laravel/framework? |
@ConnorVG kinda, but kinda not. Needs more fleshing out and what-not before it'd be a valid candidate + I think I saw there is going to be a new Rule class in 5.5 on twitter + it's so easy to just do stuff the 'stringy' way, I think majority of people would be against this being in the core...probs. |
I think it's more about extending the current Rule class that's already implemented. It won't take much to add the support here, I don't think: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Validation/Rule.php#L56-L66 |
Oh, totally, yea, for just the built in unique rule, yea. I thought you meant the whole package haha. I'd love someone to PR it, I might if I get time, but would love someone else to if they have the time for sure. |
It might even make sense just to support: |
yea, my package allows a table string, class string or Model instance. Makes it very nice. |
@ConnorVG Submitted an internals proposal to see community feedback and so we can stop polluting this thread (sorry everyone). |
When I was renaming the default users and password_resets tables into something else and then when I try to register an account, I then encountered an error:
It seems that the query still uses the default table name, and when I went to the
RegisterController.php
,the problem was caused by the validator rule
unique:users
for theemail
field. And to fix it, we need to update the validator rule to use the new table name.What I'm trying to suggest is maybe we can make it a little more dynamic rather than hardcoding it.
Since the Registration Controller is somehow tied with the
app/User
model, I'm wondering if we can include a method in the model like:and update the validator method in the
RegisterController.php
into something like:or simply:
or any better ideas?
The text was updated successfully, but these errors were encountered: