Browse Source

Merge pull request #438 from sparksp/patch-7

Fix named keys on Schema columns
Taylor Otwell 12 years ago
parent
commit
ca77cd5a17
2 changed files with 25 additions and 2 deletions
  1. 9 2
      laravel/database/schema.php
  2. 16 0
      laravel/fluent.php

+ 9 - 2
laravel/database/schema.php

@@ -120,9 +120,16 @@ class Schema {
 		{
 			foreach (array('primary', 'unique', 'fulltext', 'index') as $key)
 			{
-				if (isset($column->attributes[$key]))
+				if (isset($column->$key))
 				{
-					$table->$key($column->name);
+					if ($column->$key === true)
+					{
+						$table->$key($column->name);
+					}
+					else
+					{
+						$table->$key($column->name, $column->$key);
+					}
 				}
 			}
 		}

+ 16 - 0
laravel/fluent.php

@@ -77,4 +77,20 @@ class Fluent {
 		$this->attributes[$key] = $value;
 	}
 
+	/**
+	 * Dynamically check if an attribute is set.
+	 */
+	public function __isset($key)
+	{
+		return isset($this->attributes[$key]);
+	}
+
+	/**
+	 * Dynamically unset an attribute.
+	 */
+	public function __unset($key)
+	{
+		return unset($this->attributes[$key]);
+	}
+
 }