<input name="keyword[]" type="text" id="keyword" value="" ... required>
<input name="url[]" type="text" id="url" value="" ... required>
This is the result of input request to form an array in it:
array:4 [▼
"_token" => "LSgeBGHL6QQEkirJFcSLC4T045vb2M4afsi48NeC"
"category_id" => "1266"
"keyword" => array:2 [▼
0 => "test"
1 => "test"
]
"url" => array:2 [▼
0 => "/search/test"
1 => "/search/test"
]
]
I want to make a validation if the input array is the same and the data is already in the database before it will not be able to input. I have tried using validation as below, but it didn't work and got an error message.
public function postAdd()
{
$data = \Input::all();
$this->validate($data, [
'keyword.*' => 'required|sometimes|unique',
'url.*' => 'required|sometimes|unique'
]);
}
Please help me to be able to make the same input validation in the array and validate if the inputted data already exists in the database. Thanks!