Skip to content

Commit e7ccbf4

Browse files
authored
Merge pull request #227 from OzanKurt/patch-1
fix: `Marcoable` trait usage together with `Fluent` helper
2 parents 3d53a81 + 4009e9c commit e7ccbf4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Html/Button.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,32 @@ public function align(string $align = 'button-left'): static
429429

430430
return $this;
431431
}
432+
433+
/**
434+
* Handle dynamic calls to the fluent instance or macroable methods.
435+
*
436+
* @param string $method
437+
* @param array $parameters
438+
* @return mixed
439+
*
440+
* @throws \BadMethodCallException
441+
*/
442+
public function __call($method, $parameters)
443+
{
444+
// Check if the method is a macro (Macroable functionality).
445+
if (static::hasMacro($method)) {
446+
$macro = static::$macros[$method];
447+
448+
if ($macro instanceof Closure) {
449+
$macro = $macro->bindTo($this, static::class);
450+
}
451+
452+
return $macro(...$parameters);
453+
}
454+
455+
// Fallback to Fluent behavior if it's not a macro.
456+
$this->attributes[$method] = count($parameters) > 0 ? reset($parameters) : true;
457+
458+
return $this;
459+
}
432460
}

0 commit comments

Comments
 (0)