【发布时间】:2018-08-29 05:45:09
【问题描述】:
我有一个要验证的元素数组,这个数组有这种形式
{
"slugs" : {
1 : "prueba",
2 : "test"
}
Slugs 是输入 <input name="slugs[{{ $lang->id }}]">,数字是语言的 ID 1 = spanish / 2 = english。
我想要的是在这样的表单请求中验证这些字段的唯一性
public function rules()
{
$rules = [
//
'slugs.*' => Rule::unique('translation_entries')->where(function($query) {
//here i want to access the * that represent the lang id
//like this $query->where('lang_id','=',$query->*);
})
];
}
我可以访问唯一 Rule 类中的索引 * 吗?
【问题讨论】:
-
你使用的是什么版本的 Laravel?
标签: laravel laravel-validation