From 7862e10e187e6bb0794a6e5de032159fa8e78a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20C=2E=20For=C3=A9s?= Date: Thu, 10 Dec 2020 13:05:06 +0100 Subject: [PATCH 1/2] Add has() method to ComponentAttributeBag --- src/Illuminate/View/ComponentAttributeBag.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 0a5111037eb5..07b0a8db166f 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -56,6 +56,17 @@ public function get($key, $default = null) return $this->attributes[$key] ?? value($default); } + /** + * Determines if a given attribute exists in the attribute array. + * + * @param string $key + * @return bool + */ + public function has($key) + { + return array_key_exists($key, $this->attributes); + } + /** * Only include the given attribute from the attribute array. * From 1b29d942975f1dbd0310cc9a6abce0143e686765 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 10 Dec 2020 07:29:04 -0600 Subject: [PATCH 2/2] Update ComponentAttributeBag.php --- src/Illuminate/View/ComponentAttributeBag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 07b0a8db166f..7a2b9f959ea6 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -57,7 +57,7 @@ public function get($key, $default = null) } /** - * Determines if a given attribute exists in the attribute array. + * Determine if a given attribute exists in the attribute array. * * @param string $key * @return bool