From c100c44018c60ff4ff634ecc31aa93a2d47f7496 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 19 Apr 2022 19:28:43 +0200 Subject: [PATCH] Clarify that dependsOn() does not take class names (#110) --- README.md | 3 +++ src/NovaBelongsToDepend.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab4b855..6e97fdf 100644 --- a/README.md +++ b/README.md @@ -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') ``` diff --git a/src/NovaBelongsToDepend.php b/src/NovaBelongsToDepend.php index 0514246..9afcabe 100644 --- a/src/NovaBelongsToDepend.php +++ b/src/NovaBelongsToDepend.php @@ -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; }