Skip to content
Permalink
Browse files

remove commas from values

  • Loading branch information...
taylorotwell committed Mar 19, 2019
1 parent d90611b commit da4d4a468eee174bd619b4a04aab57e419d10ff4
Showing with 5 additions and 5 deletions.
  1. +4 −4 src/Illuminate/Validation/Rules/Unique.php
  2. +1 −1 tests/Validation/ValidationUniqueRuleTest.php
@@ -35,8 +35,8 @@ public function ignore($id, $idColumn = null)
return $this->ignoreModel($id, $idColumn);
}
$this->ignore = $id;
$this->idColumn = $idColumn ?? 'id';
$this->ignore = str_replace(',', '', $id);
$this->idColumn = str_replace(',', '', $idColumn ?? 'id');
return $this;
}
@@ -50,8 +50,8 @@ public function ignore($id, $idColumn = null)
*/
public function ignoreModel($model, $idColumn = null)
{
$this->idColumn = $idColumn ?? $model->getKeyName();
$this->ignore = $model->{$this->idColumn};
$this->idColumn = str_replace(',', '', $idColumn ?? $model->getKeyName());
$this->ignore = str_replace(',', '', $model->{$this->idColumn});
return $this;
}
@@ -17,7 +17,7 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
$rule = new Unique('table', 'column');
$rule->ignore('Taylor, Otwell', 'id_column');
$rule->where('foo', 'bar');
$this->assertEquals('unique:table,column,"Taylor, Otwell",id_column,foo,bar', (string) $rule);
$this->assertEquals('unique:table,column,"Taylor Otwell",id_column,foo,bar', (string) $rule);
$rule = new Unique('table', 'column');
$rule->ignore(null, 'id_column');

0 comments on commit da4d4a4

Please sign in to comment.
You can’t perform that action at this time.