18 Replies
even though my taxonomy is something else other than category ...it still checking slug for unique
I don't think the
->unique()
validator can be used like this. The first param it expects is $table
. Perhaps you need a custom validation rule? https://filamentphp.com/docs/2.x/forms/validation#custom-rulesyes i have used rules but how to use ignoreRecord
why unique this way is not working
The callback on unique is used to extend the unique query that's already inside the unique validation rule.
but how to use whereHas condition its giving error
Please check #✅┊rules on how to paste PHP code in here instead of screenshots. It makes it easier to read and possible to copy paste.
What if you use a simple
->unique
with callback, and build from there? At which point does it break and what's the error message?
how to use whereHas here because it showing me error here Undefined method 'whereHas'.
check the laravel docs, i dont think that method exists
Then can you tell me if i have to check two tables data for unique what to do ??
its in the laravel docs, wrap it in where()
$rule->where(fn ($query) => $query->whereHas(
Still did not work
you need to debug it then
i cant hold your hand for everything
Define "still did not work" ?
Do you have a query log to see which queries are executed? Laravel Debugbar is an easy way to add logging/monitoring.
What are you trying to accomplish anyway? Because now you're checking if there is already a model in the database with the same slug as what you are trying to save, that also has a related taxonomy record with taxonomy "kheltags". Which means that you can still add records with the same slug as a record in the database, except if that relation exists on the db record .
what I am trying to check is that it will check same slug in the table wp_terms but not entirely that table but it will other table wp_term_taxonomy which have foreign key column term_id where taxonomy column value is "kheltags" and those data will be checked
giving me this error SQLSTATE[42S22]: Column not found: 1054 Unknown column 'has' in 'where clause'
I made it work this way but still wanted do it in unique()
Strange. Eloquent "creates" magic functions, e.g. for column name you can use
->where('name', ...)
or ->whereName('...)
. But still whereHas
should be available too. Xdebug is very handy in debugging cases like this. Check it out if you want. Otherwise, try to debug however you can. Anyway, you've got at least a working solution.okay thank you