Skip to content

Commit

Permalink
remove commas from values
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 19, 2019
1 parent d90611b commit da4d4a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Validation/Rules/Unique.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/ValidationUniqueRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit da4d4a4

Please sign in to comment.