Closed ipontt-neering closed 4 weeks ago
Rule::numUnique
works well enough for my use case as it is currently,
Rule::numUnique
works well enough for my use case as it is currently,
That rules essentially does Rule::unique()
but on the RUT number column (rut_num
by default).
I guess I'll have to take a deeper look into the these rules once I have time, so I'll leave this open.
Okay, I took a look at it and the problem is simple: The ignore column parameter "id" should be NULL
string when there is no id to ignore.
If there is an ID to ignore, it should be set as "id" column name if the user didn't set it, or whatever the user has set. If the User passes a Model instance, it should be the primary key.
Since the rule does remove all arguments that are NULL
, we can simply follow the aforementioned logic rules to set RutUnique::$idColumn
to NULL
unless needed.
PHP & Platform
8.3
Database
MySQL 8
Laravel version
11.x
Have you done this?
Expectation
The expectation is that registered rules (
rut_unique:users
) should behave the same as Rule classes (or macros) (Rule::rutUnique
/new Laragear\Rut\Rules\RutUnique(...)
) and generate the same queries.Description
These are the deprecation warnings and exception thrown.
This is the "path" I observed for both methods when the
validate
method gets called on the validator. rut_unique:usersRule::rutUnique(User::class)
I've managed to fix the error locally by changing the
addExtraWheres
method from.to
Reproduction
Stack trace & logs
No response