Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.3' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 15, 2016
2 parents 040499c + 4de2ece commit 093cf02
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public function beginTransaction()
{
if ($this->transactions == 0) {
try {
$this->pdo->beginTransaction();
$this->getPdo()->beginTransaction();
} catch (Exception $e) {
if ($this->causedByLostConnection($e)) {
$this->reconnect();
Expand All @@ -613,7 +613,7 @@ public function beginTransaction()
}
}
} elseif ($this->transactions >= 1 && $this->queryGrammar->supportsSavepoints()) {
$this->pdo->exec(
$this->getPdo()->exec(
$this->queryGrammar->compileSavepoint('trans'.($this->transactions + 1))
);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Validation/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public static function exists($table, $column = 'NULL')
return new Rules\Exists($table, $column);
}

/**
* Get an in constraint builder instance.
*
* @param array $values
* @return \Illuminate\Validation\Rules\In
*/
public static function in(array $values)
{
return new Rules\In($values);
}

/**
* Get a unique constraint builder instance.
*
Expand Down
34 changes: 34 additions & 0 deletions src/Illuminate/Validation/Rules/In.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Illuminate\Validation\Rules;

class In
{
/**
* The accepted values.
*
* @var array
*/
protected $values;

/**
* Create a new in rule instance.
*
* @param array $values
* @return void
*/
public function __construct(array $values)
{
$this->values = $values;
}

/**
* Convert the rule to a validation string.
*
* @return string
*/
public function __toString()
{
return 'in:'.implode(',', $this->values);
}
}
18 changes: 18 additions & 0 deletions tests/Validation/ValidationInRuleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\In;

class ValidationInRuleTest extends PHPUnit_Framework_TestCase
{
public function testItCorrectlyFormatsAStringVersionOfTheRule()
{
$rule = new In(['Laravel', 'Framework', 'PHP']);

$this->assertEquals('in:Laravel,Framework,PHP', (string) $rule);

$rule = Rule::in([1, 2, 3, 4]);

$this->assertEquals('in:1,2,3,4', (string) $rule);
}
}

0 comments on commit 093cf02

Please sign in to comment.