I want to echo vuejs data inside a php function like so:

{{ auth()->user()->timesAddedBeer(@{{ beer.id }}) }}

But laravel gives me the following error:

syntax error, unexpected '{'

Can anybody tell me the right way to do this?

share|improve this question
    
You could use plain <?php tags instead of {{. – Andrew Oct 6 '15 at 15:38
    
That does not work since the outer braces are from the blade templating of laravel and the inner @{{ }} braces are from vuejs itself so they are not php and are needed. – Stephan-v Oct 6 '15 at 15:42
    
Maybe triple {{{ $data }}} to echo? – senty Oct 6 '15 at 19:20
    
So what's stoping you from doing something like this? <?php auth->user->()->timesAddedBeer(?> @{{ beer.id}} <?php ) ?> – Andrew Oct 6 '15 at 20:08
    
The vuejs data is loading a fraction slower than the page so the php function is trying to execute with the laravel values of the mustache binding instead of the translated value. – Stephan-v Oct 7 '15 at 22:47
up vote 2 down vote accepted

It's not possible because the server can't access the JS value at the time executing the php script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.