From 7798cc1b1d97907dcd0aedd7f855073d3ece0384 Mon Sep 17 00:00:00 2001 From: Petyo Tsonev Date: Wed, 17 Apr 2019 01:59:36 +0300 Subject: [PATCH] NovaBelongsToDepend can be placed after another fields Filter the result's before getting the exact one removes the limitation for using NovaBelongsToDepend field BEFORE any other declared fields. --- src/Http/Controllers/FieldController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Http/Controllers/FieldController.php b/src/Http/Controllers/FieldController.php index 3cf0d7c..812ad1b 100644 --- a/src/Http/Controllers/FieldController.php +++ b/src/Http/Controllers/FieldController.php @@ -24,6 +24,10 @@ public function index(NovaRequest $request) } return $field; })->flatten(); + + $fields = $fields->filter(function ($value) use ($request) { + return ($value instanceof NovaBelongsToDepend); + }); $field = $fields->first(function ($value, $key) use ($request) { return ($value instanceof NovaBelongsToDepend && $value->attribute == $request->attribute);