already created custom validation for the same but i want to pass array in custom validation from model becuase i want to check each combination of unique values.
//Service Provider
Validator::extend('unique_code', function($attribute, $data, $parameters,$validator ) {
// my code for checking unique values
});
//model of table 2
// i want to pass array of ids from my controller which is had foreign key of table 1 to check with code in table 2
public static function validate($data) {
$rule = array(
'code' => 'required|max:255|unique_code:' . array(all ids). '|unique:table2,code,NULL,id,table_1_id,' . array(all ids),
);
$messages = array(
'unique' => ':attribute has already been taken.',
);
$data = Validator::make($data, $rule, $messages);
$data->setAttributeNames(array(
'code' => ucfirst(SYS_CODE)
));
return $data;
}
above code i had tried but can't pass array from model to service provider in $parameters