Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CarlEOgden's avatar

Convert js variables to $ php variables to use in blade

Hi

My blade calls a js routine to save some invoice data, it returns those variables as:

In vuejs:

this.paymentid this.propertyid this.subtype

Convert to php:

$paymentid $propertyid $subtype

What i need to do (and I can see the js variables exist in my blade as I have div that shows v-if="paymentid > 0") is convert them from js to php.

This is so that I use a button to

{{ route('letter::select', [ 'sub_type => $subtype ]) {{

as I can't use

{{ route('letter:select', [ 'sub_type' => @{{ subtype }} ) }}

Thanks for any help! Cheers Carl.

0 likes
4 replies
Sinnbeck's avatar

You cant. Php is generated before js. That means that the route function is run before your JS is even started.

You can use ziggy to get a js version of the route helper instead :)

https://github.com/tightenco/ziggy

CarlEOgden's avatar

Thanks for that! Back to the drawing board then.

Cheers Carl.

Sinnbeck's avatar

I updated my post with a link to a package to work around the issue.

CarlEOgden's avatar

Thank you, will investigate this further.

Cheers Carl.

Please or to participate in this conversation.