I've made a custom validator in my Laravel application, and I want to make a custom error. Ideally, this will be Your image must be at least 500 by 500 pixels.
However, I cannot figure out how to get the parameters (500, 500) in the validation.php file.
This is the current error message:
"image_dimensions" => "Your :attribute must be at least GET PARAMETERS HERE",
Here's the validator:
Validator::extend('image_dimensions', function($attribute, $value, $parameters) {
$image = Image::make($value);
$min_width = $parameters[0];
$min_height = $parameters[1];
if ($image->getWidth() < $min_width) {
return false;
} else if ($image->getHeight() < $min_height) {
return false;
}
return true;
});
And here I am using it:
$validator = Validator::make(
array(
'image' => Input::file('file'),
),
array(
'image' => 'image_dimensions:500,500'
)
);
How do I fetch the parameters given in my error message?