public function morphTo($name = null, $type = null, $id = null)
{
// If no name is provided, we will use the backtrace to get the function name
// since that is most likely the name of the polymorphic interface. We can
// use that to get both the class and foreign key that will be utilized.
if (is_null($name)) {
list(, $caller) = debug_backtrace(false);
$name = snake_case($caller['function']);
}
// Next we will guess the type and ID if necessary. The type and IDs may also
// be passed into the function so that the developers may manually specify
// them on the relations. Otherwise, we will just make a great estimate.
list($type, $id) = $this->getMorphs($name, $type, $id);
$class = $this->{$type};
return $this->belongsTo($class, $id);
}