Validate an array of integers
问题 Given an array of integers: [1, 2, 3, 4, ...] How can I use the validator to check if each of these exists in a table? Possible without a foreach loop? $validator = Validator::make($request->all(), [ 'array' => 'required|exists:users,id' ]); 回答1: Your validation as written should work. If the exists validation is used with an array, it will automatically use where in for the exists query. So, given your validation as you have written, the validation will get the count of the users records