diff --git a/composer.json b/composer.json index b23a113..b49d815 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "email": "povilas@webcoderpro.com" } ], - "version": "0.4.5", + "version": "0.4.6", "require": { "illuminate/html": "5.0.*@dev", "intervention/image": "^2.3", diff --git a/src/Builders/RequestBuilder.php b/src/Builders/RequestBuilder.php index 1af674c..9090af8 100644 --- a/src/Builders/RequestBuilder.php +++ b/src/Builders/RequestBuilder.php @@ -116,20 +116,38 @@ private function buildRules($type) break; } } elseif ($field->type == 'file' || $field->type == 'photo') { - switch ($field->validation) { - case 'required': - $rules .= "'$field->title' => 'max:$field->size|$field->validation', \r\n "; - break; - case 'required|unique': - $camelName = Str::camel($this->name); - // Insert table names - $tableName = strtolower($camelName); - $rules .= "'$field->title' => 'max:$field->size|$field->validation:$tableName,$field->title,'." . '$this->' . $this->request . ", \r\n "; - break; - default: - // We got a file field which has a bit different validation - $rules .= "'$field->title' => 'max:$field->size', \r\n "; - break; + if ($type == 0) { + switch ($field->validation) { + case 'required': + $rules .= "'$field->title' => 'max:$field->size|$field->validation', \r\n "; + break; + case 'required|unique': + $camelName = Str::camel($this->name); + // Insert table names + $tableName = strtolower($camelName); + $rules .= "'$field->title' => 'max:$field->size|$field->validation:$tableName,$field->title,'." . '$this->' . $this->request . ", \r\n "; + break; + default: + // We got a file field which has a bit different validation + $rules .= "'$field->title' => 'max:$field->size', \r\n "; + break; + } + } else { + switch ($field->validation) { + case 'required': + $rules .= "'$field->title' => 'max:$field->size', \r\n "; + break; + case 'required|unique': + $camelName = Str::camel($this->name); + // Insert table names + $tableName = strtolower($camelName); + $rules .= "'$field->title' => 'max:$field->size|$field->validation:$tableName,$field->title,'." . '$this->' . $this->request . ", \r\n "; + break; + default: + // We got a file field which has a bit different validation + $rules .= "'$field->title' => 'max:$field->size', \r\n "; + break; + } } } elseif ($field->type == 'money') { diff --git a/src/Builders/ViewsBuilder.php b/src/Builders/ViewsBuilder.php index a439f03..6900af8 100644 --- a/src/Builders/ViewsBuilder.php +++ b/src/Builders/ViewsBuilder.php @@ -173,7 +173,7 @@ private function buildEditForm() foreach ($this->fields as $field) { $title = $field->label; $label = $field->title; - if (in_array($field->validation, $this->starred) && $field->type != 'password') { + if (in_array($field->validation, $this->starred) && $field->type != 'password' && $field->type != 'file' && $field->type != 'photo') { $title .= '*'; } if ($field->type == 'relationship') {