original_string: public static function transaction($closure)
  	{
  		$connection = static::connection();
  
  		try
  		{
  			$connection->transaction();
  
  			if ($closure() === false)
  			{
  				$connection->rollback();
  				return false;
  			}
  			else
  				$connection->commit();
  		}
  		catch (\Exception $e)
  		{
  			$connection->rollback();
  			throw $e;
  		}
  		return true;
  	}
code: public static function transaction($closure)
  	{
  		$connection = static::connection();
  
  		try
  		{
  			$connection->transaction();
  
  			if ($closure() === false)
  			{
  				$connection->rollback();
  				return false;
  			}
  			else
  				$connection->commit();
  		}
  		catch (\Exception $e)
  		{
  			$connection->rollback();
  			throw $e;
  		}
  		return true;
  	}
code_tokens: public static function transaction ( $ closure ) { $ connection = static :: connection ( ) ; try { $ connection -> transaction ( ) ; if ( $ closure ( ) === false ) { $ connection -> rollback ( ) ; return false ; } else $ connection -> commit ( ) ; } catch ( \ Exception $ e ) { $ connection -> rollback ( ) ; throw $ e ; } return true ; }
docstring: Executes a block of code inside a database transaction.
  
  <code>
  YourModel::transaction(function()
  {
  YourModel::create(array("name" => "blah"));
  });
  </code>
  
  If an exception is thrown inside the closure the transaction will
  automatically be rolled back. You can also return false from your
  closure to cause a rollback:
  
  <code>
  YourModel::transaction(function()
  {
  YourModel::create(array("name" => "blah"));
  throw new Exception("rollback!");
  });
  
  YourModel::transaction(function()
  {
  YourModel::create(array("name" => "blah"));
  return false; # rollback!
  });
  </code>
  
  @param Closure $closure The closure to execute. To cause a rollback have your closure return false or throw an exception.
  @return boolean True if the transaction was committed, False if rolled back.
docstring_tokens: Executes a block of code inside a database transaction .