From da61279884cba0b388521dbd1cd6afd2d8861494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20C=2E=20For=C3=A9s?= Date: Thu, 10 Dec 2020 14:29:11 +0100 Subject: [PATCH] [8.x] Add has() method to ComponentAttributeBag (#35562) * Add has() method to ComponentAttributeBag * Update ComponentAttributeBag.php Co-authored-by: Taylor Otwell --- 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..7a2b9f959ea6 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); } + /** + * Determine 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. *