laravel/framework — pull request #3019 by adamwathan (2013-12-22 15:52:42+00:00)
Title: Autodetect namespace in Eloquent relationships if necessary

Got sick of writing fully qualified namespaces when defining relationships between classes that were in the same namespace.

This PR allows you to specify just the classname in a relationship. If it's necessary to namespace that class for the relationship to work, it will be done automatically.

```php
belongsTo('\User');

// Will first try to use \Foo\Bar\User and fallback to \User if the
// namespaced version doesn't exist
return $this->belongsTo('User');

// Will immediately use \Foo\Bar\User
return $this->belongsTo('\Foo\Bar\User');

// First attempts \Foo\Bar\Foo\Bar\User but falls back to \Foo\Bar\User
// since Foo\Bar\Foo\Bar\User does not exist
return $this->belongsTo('Foo\Bar\User');
}
}
```