On this page
ComponentAttributeBag
class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate (View source)
Traits
Properties
| static protected array | $macros | The registered string macros.  | 
      from Macroable | 
| protected array | $attributes | The raw array of attributes.  | 
      
Methods
| $this|TWhenReturnType | when($value = null, callable $callback = null, callable $default = null)  Apply the callback if the given "value" is (or resolves to) truthy.  | 
      from Conditionable | 
| $this|TUnlessReturnType | unless($value = null, callable $callback = null, callable $default = null)  Apply the callback if the given "value" is (or resolves to) falsy.  | 
      from Conditionable | 
| static void | macro(string $name, object|callable $macro)  Register a custom macro.  | 
      from Macroable | 
| static void | mixin(object $mixin, bool $replace = true)  Mix another object into the class.  | 
      from Macroable | 
| static bool | hasMacro(string $name)  Checks if macro is registered.  | 
      from Macroable | 
| static void | flushMacros()  Flush the existing macros.  | 
      from Macroable | 
| static mixed | __callStatic(string $method, array $parameters)  Dynamically handle calls to the class.  | 
      from Macroable | 
| mixed | __call(string $method, array $parameters)  Dynamically handle calls to the class.  | 
      from Macroable | 
| void | __construct(array $attributes = [])  Create a new component attribute bag instance.  | 
      |
| mixed | first(mixed $default = null)  Get the first attribute's value.  | 
      |
| mixed | get(string $key, mixed $default = null)  Get a given attribute from the attribute array.  | 
      |
| bool | has(string $key)  Determine if a given attribute exists in the attribute array.  | 
      |
| bool | missing(string $key)  Determine if a given attribute is missing from the attribute array.  | 
      |
| ComponentAttributeBag | only(mixed $keys)  Only include the given attribute from the attribute array.  | 
      |
| ComponentAttributeBag | except(mixed|array $keys)  Exclude the given attribute from the attribute array.  | 
      |
| ComponentAttributeBag | filter(callable $callback)  Filter the attributes, returning a bag of attributes that pass the filter.  | 
      |
| ComponentAttributeBag | whereStartsWith(string|string[] $needles)  Return a bag of attributes that have keys starting with the given value / pattern.  | 
      |
| ComponentAttributeBag | whereDoesntStartWith(string|string[] $needles)  Return a bag of attributes with keys that do not start with the given value / pattern.  | 
      |
| ComponentAttributeBag | thatStartWith(string|string[] $needles)  Return a bag of attributes that have keys starting with the given value / pattern.  | 
      |
| ComponentAttributeBag | onlyProps(mixed|array $keys)  Only include the given attribute from the attribute array.  | 
      |
| ComponentAttributeBag | exceptProps(mixed|array $keys)  Exclude the given attribute from the attribute array.  | 
      |
| array | extractPropNames(mixed|array $keys)  Extract prop names from given keys.  | 
      |
| ComponentAttributeBag | class(mixed|array $classList)  Conditionally merge classes into the attribute bag.  | 
      |
| ComponentAttributeBag | style(mixed|array $styleList)  Conditionally merge styles into the attribute bag.  | 
      |
| ComponentAttributeBag | merge(array $attributeDefaults = [], bool $escape = true)  Merge additional attributes / values into the attribute bag.  | 
      |
| bool | shouldEscapeAttributeValue(bool $escape, mixed $value)  Determine if the specific attribute value should be escaped.  | 
      |
| AppendableAttributeValue | prepends(mixed $value)  Create a new appendable attribute value.  | 
      |
| mixed | resolveAppendableAttributeDefault(array $attributeDefaults, string $key, bool $escape)  Resolve an appendable attribute value default value.  | 
      |
| array | getAttributes()  Get all of the raw attributes.  | 
      |
| void | setAttributes(array $attributes)  Set the underlying attributes.  | 
      |
| string | toHtml()  Get content as a string of HTML.  | 
      |
| HtmlString | __invoke(array $attributeDefaults = [])  Merge additional attributes / values into the attribute bag.  | 
      |
| bool | offsetExists(string $offset)  Determine if the given offset exists.  | 
      |
| mixed | offsetGet(string $offset)  Get the value at the given offset.  | 
      |
| void | offsetSet(string $offset, mixed $value)  Set the value at a given offset.  | 
      |
| void | offsetUnset(string $offset)  Remove the value at the given offset.  | 
      |
| Traversable | getIterator()  Get an iterator for the items.  | 
      |
| string | __toString()  Implode the attributes into a single HTML ready string.  | 
      
Details
$this|TWhenReturnType when($value = null, callable $callback = null, callable $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType unless($value = null, callable $callback = null, callable $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool hasMacro(string $name)
Checks if macro is registered.
static void flushMacros()
Flush the existing macros.
static mixed __callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed __call(string $method, array $parameters)
Dynamically handle calls to the class.
void __construct(array $attributes = [])
Create a new component attribute bag instance.
mixed first(mixed $default = null)
Get the first attribute's value.
mixed get(string $key, mixed $default = null)
Get a given attribute from the attribute array.
bool has(string $key)
Determine if a given attribute exists in the attribute array.
bool missing(string $key)
Determine if a given attribute is missing from the attribute array.
ComponentAttributeBag only(mixed $keys)
Only include the given attribute from the attribute array.
ComponentAttributeBag except(mixed|array $keys)
Exclude the given attribute from the attribute array.
ComponentAttributeBag filter(callable $callback)
Filter the attributes, returning a bag of attributes that pass the filter.
ComponentAttributeBag whereStartsWith(string|string[] $needles)
Return a bag of attributes that have keys starting with the given value / pattern.
ComponentAttributeBag whereDoesntStartWith(string|string[] $needles)
Return a bag of attributes with keys that do not start with the given value / pattern.
ComponentAttributeBag thatStartWith(string|string[] $needles)
Return a bag of attributes that have keys starting with the given value / pattern.
ComponentAttributeBag onlyProps(mixed|array $keys)
Only include the given attribute from the attribute array.
ComponentAttributeBag exceptProps(mixed|array $keys)
Exclude the given attribute from the attribute array.
protected array extractPropNames(mixed|array $keys)
Extract prop names from given keys.
ComponentAttributeBag class(mixed|array $classList)
Conditionally merge classes into the attribute bag.
ComponentAttributeBag style(mixed|array $styleList)
Conditionally merge styles into the attribute bag.
ComponentAttributeBag merge(array $attributeDefaults = [], bool $escape = true)
Merge additional attributes / values into the attribute bag.
protected bool shouldEscapeAttributeValue(bool $escape, mixed $value)
Determine if the specific attribute value should be escaped.
AppendableAttributeValue prepends(mixed $value)
Create a new appendable attribute value.
protected mixed resolveAppendableAttributeDefault(array $attributeDefaults, string $key, bool $escape)
Resolve an appendable attribute value default value.
array getAttributes()
Get all of the raw attributes.
void setAttributes(array $attributes)
Set the underlying attributes.
string toHtml()
Get content as a string of HTML.
HtmlString __invoke(array $attributeDefaults = [])
Merge additional attributes / values into the attribute bag.
bool offsetExists(string $offset)
Determine if the given offset exists.
mixed offsetGet(string $offset)
Get the value at the given offset.
void offsetSet(string $offset, mixed $value)
Set the value at a given offset.
void offsetUnset(string $offset)
Remove the value at the given offset.
Traversable getIterator()
Get an iterator for the items.
string __toString()
Implode the attributes into a single HTML ready string.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
 https://laravel.com/api/10.x/Illuminate/View/ComponentAttributeBag.html