Skip to content

Commit

Permalink
Merge pull request #7 from Energon7/master
Browse files Browse the repository at this point in the history
Fix working with custom rules
  • Loading branch information
kongulov authored Dec 16, 2020
2 parents ec18961 + 5b50e72 commit 92c77de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/NovaTabTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drobee\NovaSluggable\SluggableText;
use Epartment\NovaDependencyContainer\NovaDependencyContainer;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Laravel\Nova\Fields\Field;
Expand Down Expand Up @@ -116,12 +117,14 @@ protected function createTranslatedField(Field $originalField, string $locale):
return $translatedField;
}

public function setRules($translatedField){
public function setRules($translatedField) {

$translatedField->creationRules = $this->setUnique($translatedField->creationRules, $translatedField->meta['locale']);
$translatedField->updateRules = $this->setUnique($translatedField->updateRules, $translatedField->meta['locale']);

foreach ($translatedField->rules as $key => &$rule) {
if ($rule instanceof Rule) continue;

if (strpos($rule, 'required_lang') !== false){
$langs = explode(',', Str::after($rule,'required_lang:'));

Expand Down

0 comments on commit 92c77de

Please sign in to comment.