Tuesday, March 7, 2017

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'
]);



via user7675955

Advertisement