Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Add has() method to ComponentAttributeBag #35562

Merged
merged 2 commits into from Dec 10, 2020

Conversation

ConsoleTVs
Copy link
Contributor

@ConsoleTVs ConsoleTVs commented Dec 10, 2020

Allows to determine if a given attribute is present on a component.

While it's true that we can already guess if the property is present using get(), the has() method's job is only to check if it exists or not (returning a bool) allowing to build safer typed code that does not rely on type-casting attribute values.

@if ($attributes->has('class'))
    <div>Class Attribute Present</div>
@endif

@taylorotwell taylorotwell merged commit da61279 into laravel:8.x Dec 10, 2020
ConsoleTVs added a commit to ConsoleTVs/docs that referenced this pull request Dec 28, 2020
Small addition to the docs to add the existing `get` and `has` methods of the component attributes bag.

Additional: laravel/framework#35562
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants