Skip to content

Commit

Permalink
fix(validation): correct values to use
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 23, 2023
1 parent 808a4b0 commit 1a3a078
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/Validation/DatabaseRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public function is_unique_compositely(
$parameter_count = count($combined_parameters);
for ($i = 1; $i < $parameter_count; $i++) {
$composite_column_data = $combined_parameters[$i];
$position_of_equals = strpos($composite_column_data, "=") || -1;
$position_of_pointer = strpos($composite_column_data, "->") || -1;
$position_of_equals = strpos($composite_column_data, "=");
$position_of_pointer = strpos($composite_column_data, "->");

$position_of_equals = $position_of_equals === false ? -1 : $position_of_equals;
$position_of_pointer = $position_of_pointer === false ? -1 : $position_of_pointer;
Expand Down Expand Up @@ -169,7 +169,7 @@ function($builder, $extra_parameter) {
);
},
model($essential_parameters[0], false)
->where($essential_parameters[0], $value)
->where($essential_parameters[1], $value)
);
$found_model = $query_builder->withDeleted()->first();

Expand All @@ -179,7 +179,7 @@ function($builder, $extra_parameter) {
return false;
}

$ignored_parameters = explode("=", $parameters[2]);
$ignored_parameters = explode("=", $parameters[1]);
if (count($ignored_parameters) < 2) {
$error = 'Ignore column and ignore value is required'
.' in "{0}" to check if the value in {field} is unique.';
Expand All @@ -188,7 +188,7 @@ function($builder, $extra_parameter) {

$column_name = $ignored_parameters[0];
$column_value = $ignored_parameters[1];
if ($found_model->$column_name !== $column_value) {
if (strval($found_model->$column_name) !== $column_value) {
$error = '{field} must be a unique value in the database.';
return false;
}
Expand Down

0 comments on commit 1a3a078

Please sign in to comment.