From 21dfc4f0b205cc7a9e1206e176dde1569e6dcef9 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 20 Apr 2024 00:00:04 +0200 Subject: [PATCH] Add findByKey to FieldCollection --- app/Form/Data/FieldCollection.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Form/Data/FieldCollection.php b/app/Form/Data/FieldCollection.php index 3c6c6d7b..73742ca3 100644 --- a/app/Form/Data/FieldCollection.php +++ b/app/Form/Data/FieldCollection.php @@ -70,7 +70,12 @@ class FieldCollection extends Collection public function find(Field $givenField): ?Field { - return $this->first(fn ($field) => $field->key === $givenField->key); + return $this->findByKey($givenField->key); + } + + public function findByKey(string $key): ?Field + { + return $this->first(fn ($field) => $field->key === $key); } /**