Browse Source

Fixing bugs in eloquent relating to namespaces.

Taylor Otwell 12 years ago
parent
commit
30204e082b
2 changed files with 3 additions and 3 deletions
  1. 2 2
      laravel/database/eloquent/relationships/relationship.php
  2. 1 1
      laravel/helpers.php

+ 2 - 2
laravel/database/eloquent/relationships/relationship.php

@@ -62,7 +62,7 @@ abstract class Relationship extends Query {
 		// namespace, and we'll append "_id" to the name.
 		if (is_object($model))
 		{
-			$model = get_class($model);
+			$model = class_basename($model);
 		}
 
 		return strtolower(basename($model).'_id');
@@ -88,7 +88,7 @@ abstract class Relationship extends Query {
 	 */
 	protected function foreign_key()
 	{
-		return Relationship::foreign($this->base, $this->foreign);
+		return static::foreign($this->base, $this->foreign);
 	}
 
 }

+ 1 - 1
laravel/helpers.php

@@ -388,7 +388,7 @@ function class_basename($class)
 {
 	if (is_object($class)) $class = get_class($class);
 
-	return basename($class);
+	return basename(str_replace('\\', '/', $class));
 }
 
 /**