mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-24 00:44:09 -05:00
Only force unique columns to be unique when they aren't empty (otherwise, use required to ensure the column is empty)
This commit is contained in:
parent
8f4764f9b6
commit
ae2f980135
1 changed files with 4 additions and 2 deletions
|
@ -218,11 +218,13 @@ class DashboardController extends Controller {
|
||||||
return 'required:' . implode(',', $empty);
|
return 'required:' . implode(',', $empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to ensure unique columns are unique
|
// check to ensure unique columns are unique when they aren't empty
|
||||||
$not_unique = [];
|
$not_unique = [];
|
||||||
|
|
||||||
foreach ($model_class::$dashboard_columns as $column) {
|
foreach ($model_class::$dashboard_columns as $column) {
|
||||||
if ($request->has($column['name']) && array_key_exists('unique', $column) && $column['unique'] && $model_class::where($column['name'], $request[$column['name']])->where('id', '!=', $item->id)->exists()) {
|
$column_name = $column['name'];
|
||||||
|
|
||||||
|
if ($request->has($column['name']) && $request->$column_name != '' && array_key_exists('unique', $column) && $column['unique'] && $model_class::where($column['name'], $request[$column['name']])->where('id', '!=', $item->id)->exists()) {
|
||||||
if (array_key_exists('title', $column)) {
|
if (array_key_exists('title', $column)) {
|
||||||
array_push($not_unique, "'" . $column['title'] . "'");
|
array_push($not_unique, "'" . $column['title'] . "'");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue