Skip to content

Commit

Permalink
Switch to using DataType name instead of slug in BREAD unique validat…
Browse files Browse the repository at this point in the history
…ion (#3040)
  • Loading branch information
jpolive authored and fletch3555 committed Apr 30, 2018
1 parent c127d06 commit f3eb501
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public function insertUpdateData($request, $slug, $rows, $data)
*
* @return mixed
*/
public function validateBread($request, $data, $slug = null, $id = null)
public function validateBread($request, $data, $name = null, $id = null)
{
$rules = [];
$messages = [];
$customAttributes = [];
$is_update = $slug && $id;
$is_update = $name && $id;

$fieldsWithValidationRules = $this->getFieldsWithValidationRules($data);

Expand All @@ -162,7 +162,7 @@ public function validateBread($request, $data, $slug = null, $id = null)
if ($is_update) {
foreach ($rules[$fieldName] as &$fieldRule) {
if (strpos(strtoupper($fieldRule), 'UNIQUE') !== false) {
$fieldRule = \Illuminate\Validation\Rule::unique($slug)->ignore($id);
$fieldRule = \Illuminate\Validation\Rule::unique($name)->ignore($id);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/VoyagerBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function update(Request $request, $id)
$this->authorize('edit', $data);

// Validate fields with ajax
$val = $this->validateBread($request->all(), $dataType->editRows, $slug, $id);
$val = $this->validateBread($request->all(), $dataType->editRows, $dataType->name, $id);

if ($val->fails()) {
return response()->json(['errors' => $val->messages()]);
Expand Down

0 comments on commit f3eb501

Please sign in to comment.