Skip to content

Commit

Permalink
Clarify that dependsOn() does not take class names (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske authored Apr 19, 2022
1 parent 9165ca6 commit c100c44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function fields(Request $request)
}
```

Method `dependsOn` takes the `name` property of the fields it depends on.
Use the field's `attribute` value if you specified it manually.

## Options

```placeholder('Optional Placeholder') ```
Expand Down
13 changes: 10 additions & 3 deletions src/NovaBelongsToDepend.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ public function optionsResolve($callback)
return $this;
}

public function dependsOn(string ...$classNames): NovaBelongsToDepend
/**
* You may depend on other NovaBelongsToDepend fields only.
*
* @param string ...$attributeNames "name" value of the fields this field
* depends on, or their "attribute" value
* if it is different.
*/
public function dependsOn(string ...$attributeNames): NovaBelongsToDepend
{
foreach ($classNames as &$value) {
foreach ($attributeNames as &$value) {
$value = Str::lower($value);
}
$this->dependsOn = $classNames;
$this->dependsOn = $attributeNames;
return $this;
}

Expand Down

0 comments on commit c100c44

Please sign in to comment.