private function validateRelation($model, $relation)
{
$class = get_class($model);
if (!method_exists($model, $relation)) {
throw new \LogicException(sprintf('%s does not have method \'%s\'.', $class, $relation));
}
if (!$model->{$relation}() instanceof \Illuminate\Database\Eloquent\Relations\Relation) {
throw new \LogicException(sprintf('%s \'%s\' is not an instance of Illuminate\\Database\\Eloquent\\Relations\\Relation.', $class, $relation));
}
}