Laravel - Blade Templates - Non Class Attribute Merging

When merging attributes that are not class attributes, the values provided to the merge method will be considered the "default" values of the attribute. However, unlike the class attribute, these attributes will not be merged with injected attribute values. Instead, they will be overwritten. For example, a button component's implementation may look like the following:

    
    
	

To render the button component with a custom type, it may be specified when consuming the component. If no type is specified, the button type will be used:

    
    
        Submit
    
	

The rendered HTML of the button component in this example would be:

    
    
	

If you would like an attribute other than class to have its default value and injected values joined together, you may use the prepends method. In this example, the data-controller attribute will always begin with profile-controller and any additional injected data-controller values will be placed after this default value:

    
    
merge(['data-controller' => $attributes->prepends('profile-controller')]) }}> {{ $slot }}