Replies: 1 comment
-
I define the macro with use Spatie\Html\Html class, within the boot method of App\Providers\AppServiceProvider class: use Money\Money;
use Spatie\Html\Html;
Html::macro('money', function (string $name, string|Money $value = null) {
/** @var \Spatie\Html\Html $this */
$value = $this->value($name, $value);
if ($value instanceof Money) {
$value = $value->getAmount();
}
return $this->text($name, $value);
}); and calling in blade files with this {{ html()->money('amount') }} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I want to create custom element which I'll use Bootstrap/TailwindCss class for form group, I did not find a way to create a macro in the documentation
Beta Was this translation helpful? Give feedback.
All reactions