From 2692777101bcd8aba39700fd323ad407c413239d Mon Sep 17 00:00:00 2001
From: Jens Segers <segers.jens@gmail.com>
Date: Sat, 14 Dec 2013 19:04:55 +0100
Subject: [PATCH] Adding nullable method to Blueprint, fixes #90

---
 src/Jenssegers/Mongodb/Schema/Blueprint.php | 22 +++++++++++++++------
 tests/SchemaTest.php                        | 16 +++++++++++++++
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/Jenssegers/Mongodb/Schema/Blueprint.php b/src/Jenssegers/Mongodb/Schema/Blueprint.php
index 5a59a7c..48b2a78 100644
--- a/src/Jenssegers/Mongodb/Schema/Blueprint.php
+++ b/src/Jenssegers/Mongodb/Schema/Blueprint.php
@@ -44,7 +44,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 *
 	 * @param  string|array  $columns
 	 * @param  array         $options
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function index($columns = null, $options = array())
 	{
@@ -72,7 +72,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 * Indicate that the given index should be dropped.
 	 *
 	 * @param  string|array  $columns
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function dropIndex($columns = null)
 	{
@@ -90,7 +90,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 * Specify a unique index for the collection.
 	 *
 	 * @param  string|array  $columns
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function unique($columns = null, $name = null)
 	{
@@ -104,7 +104,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 * Specify a non blocking index for the collection.
 	 *
 	 * @param  string|array  $columns
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function background($columns = null)
 	{
@@ -118,7 +118,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 * Specify a sparse index for the collection.
 	 *
 	 * @param  string|array  $columns
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function sparse($columns = null)
 	{
@@ -134,7 +134,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 	 *
 	 * @param  string|array  $columns
 	 * @param  int           $seconds
-	 * @return bool
+	 * @return Blueprint
 	 */
 	public function expire($columns, $seconds)
 	{
@@ -168,6 +168,16 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
 		$this->collection->drop();
 	}
 
+	/**
+	 * Allow an attribute to be null, does not do anything.
+	 *
+	 * @return Blueprint
+	 */
+	public function nullable()
+	{
+		return $this;
+	}
+
 	/**
 	 * Add a new column to the blueprint.
 	 *
diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php
index 1ef5de3..3fafcc6 100644
--- a/tests/SchemaTest.php
+++ b/tests/SchemaTest.php
@@ -92,6 +92,22 @@ class SchemaTest extends PHPUnit_Framework_TestCase {
 		$this->assertEquals(60, $index['expireAfterSeconds']);
 	}
 
+	public function testSoftDeletes()
+	{
+		Schema::collection('newcollection', function($collection)
+		{
+			$collection->softDeletes();
+		});
+
+		Schema::collection('newcollection', function($collection)
+		{
+			$collection->string('email')->nullable()->index();
+		});
+
+		$index = $this->getIndex('newcollection', 'email');
+		$this->assertEquals(1, $index['key']['email']);
+	}
+
 	public function testFluent()
 	{
 		Schema::collection('newcollection', function($collection)
-- 
2.18.1