How do i change where laravel does it queries on functions like :
$request->validate([
'username' => 'required|string',
'email' => 'required|string|email|unique:users',
'password' => 'required|string'
]);?
It always does it queries on the table 'users' which is a laravel default table that I don't use
It make the query on the users table because when you use the unique
validation rule you can pass the name of the table on which eloquent must search for the input value which is being validate.
$request->validate([
'username' => 'required|string',
'email' => 'required|string|email|unique:users',
'password' => 'required|string'
]);?
Your validation rule for email
will search for the existance of the given email
in the users
table because it's the name of table which you pass as the first argument of unique
. You can change it.
The unique
rule take parameters like this unique:table_name:column_name