'call_signs' => [
'required', 'array', 'min:1',
'call_signs.*.call_sign' => [
Rule::unique('call_signs', 'call_sign')->whereNull('deleted_at')->ignore($user->id, 'user_id')
]
],
this is my unique code it gives me the error
call_signs is an array
BadMethodCallException Method Illuminate\Validation\Validator::validateUnique:callSigns,callSign,"12",userId,deletedAt,"NULL" does not exist.
my Callsign table has softDelete
Laravel's Unique Validation Rule provides only ignore
method and not whereNull
method. Please note that whereNull
method is part of Database Query Builder.
Also, it is usually not good to check for uniqueness on soft deletes on tables. You should consider using hard delete for such use case.
Anyway, if you want to use for some reason, you can create your own unique custom validation rule. You can read more about ithere , contains example also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.