Saturday, May 20, 2017

Validation unique values from array

I have a for add an array.

In a controller I use:

$input = $request->all();
$name = explode(PHP_EOL, $input['name']);

$this->validate($request, [
    'name' => Rule::unique('table1')->where(function ($query) {
        global $name;
        $query->whereIn('name', $name);
    })
]);

But it does not work. How to validation array for unique values?

Sorry for my english.



via zerg

Advertisement