From d77646629931db699c066f5f841622f61b8d90d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20C=2E=20For=C3=A9s?= Date: Mon, 28 Dec 2020 21:08:22 +0100 Subject: [PATCH] Add attribute checking and getting docs. Small addition to the docs to add the existing `get` and `has` methods of the component attributes bag. Additional: https://github.com/laravel/framework/pull/35562 --- blade.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/blade.md b/blade.md index a0554212db..0fcdf25d0e 100644 --- a/blade.md +++ b/blade.md @@ -933,6 +933,21 @@ Using the `first` method, you may render the first attribute in a given attribut {{ $attributes->whereStartsWith('wire:model')->first() }} + +#### Checking or Getting Attributes + +If you would like to check if an attribute is present on the component, you may use the `has` method. This method accepts the attribute name as a parameter and +returns a boolean indicating whether or not the attribute is present. + + @if ($attributes->has('class')) +
Class attribute is present
+ @endif + +In addition to checking if the attribute is present, you can also get the specific attribute value by using the `get` method. This method does also accept the attribute +name as the first parameter and will return its value. + + {{ $attributes->get('class') }} + ### Slots