更新时间:2022-11-01 10:12:32
将数组放大为字符串并以逗号连接.
Implode the array as a string and join it on commas.
'employee' => 'required|in:'.$employee->implode('id', ', '),
这将生成验证器在进行in
比较时期望的正确的逗号分隔的字符串.
This will make the correct comma separated string that the validator expects when making an in
comparison.
修改
这仍然有效,但已不再是 Laravelesque 的使用方式.请参阅@nielsiano的答案.
This still works, but is not the Laravelesque way of doing it anymore. See the answer by @nielsiano.