Skip to content

Instantly share code, notes, and snippets.

View nafplann's full-sized avatar

Abdul Manaf nafplann

View GitHub Profile
Validator::extend('object_exists', function ($attribute, $value, $parameters, $validator) {
$class = '\App\\' . ucfirst($parameters[0]);
if (is_array($value)) {
foreach ($value as $id) {
$object = call_user_func([$class, 'find'], $id);
if (is_null($object)) return false;
}
return true;
}