You can't do that. PHP is rendered on the server. Vue is client side. If you want to send any Vue data to the server you will have to use an AJAX request.
Sep 14, 2015
10
Level 10
How to pass Vue variables to Php functions
I've decided to use pusher and vue.js for my project.
I've this chunk of code in my blade view file:
@foreach($backers as $backer)
<div class="donation-container">
<div class="backer-avatar">{!! backerAvatar($backer->gravatar_user, $backer->name) !!}</div>
<h3>${{number_format($backer->amount)}} <span> by <strong>@if($backer->hide_name=='1') Anonymous @else {{$backer->name}} @endif</strong></span> </h3>
<div class="text-left backer-msg">{{$backer->message}}</div>
<span class="time_stamp text-left">- {{Carbon::createFromTimeStamp(strtotime($backer->created_at))->diffForHumans()}}</span>
</div>
@endforeach
and Im using Vue to push contents like this:
<div id="showNewDonation" class="donation-container">
<div v-repeat="backer: backers">
<h3>@{{ backer.backer.amount }} <span> <strong> @{{ backer.backer.name }} </strong></span> </h3>
<div class="text-left backer-msg">@{{ backer.backer.message }}</div>
</div>
</div>
But how can I pass certain Vue variables to php functions such as :
{{Carbon::createFromTimeStamp(strtotime(backer.backer.created_at))->diffForHumans()}}
Level 8
Please or to participate in this conversation.