Alvin FZ
Alvin FZ

Reputation: 11

How To use Blade Directive in Component

I Have a blade directive, register in AppServiceProvider, @rupiah

I want to use my directive in my laravel component.

<x-form.input name="NLTRX" label="Nilai Transaksi" disabled="true" value="{{ rupiah($retailPending['NLTRX']) }}" />

But its return error, Call to undefined function rupiah().

Any solutions?

I try using value="{{ rupiah($retailPending['NLTRX']) }}" :value=" rupiah($retailPending['NLTRX']) " :value="@rupiah($retailPending['NLTRX']) " It did'nt work either

Upvotes: 1

Views: 33

Answers (1)

Indrasis Roy
Indrasis Roy

Reputation: 1

Instead of calling rupiah() in the attribute, you can use the directive inside the component.

Modify your Blade component template (form/input.blade.php):

<input type="text" name="{{ $name }}" value="@rupiah($value)" {{ $attributes }} />

Then, use the component like this:

<x-form.input name="NLTRX" label="Nilai Transaksi" disabled="true" :value="$retailPending['NLTRX']" />

Upvotes: 0

Related Questions