Alejandro Muñoz Alejandro Muñoz - 5 months ago 50
PHP Question

Laravel,blade, vue.js and @if (@{{ }})

I am having a problem with variables devielve vue.js me ... I explain better

<tr

@if(@{{users.id}} != 1) // this is the error

Class="danger"
@else
class="success"
@endif
>


I can not define a @if (@ {{user.id in laravel

before defined

@foreach($datos as $dato)
<tbody id={{$dato->id}}>
<tr
@if($dato->id !=1)
class="danger"
@else
Class="success"
@endif >


and it worked but I had to put a select box, and Use varaible vue.js to collect and return the data I...

excuse my English is not my mother tongue and hinders me

Answer

I do not believe you can use vuejs code (such as your @{{users.id}}) inside a laravel @if() because everything inside the @if() is being treated as PHP code. If it makes sense in your particular application, make use of vuejs's v-if implementation, such as <div v-if="users.id !== 1"> INSERT WHATEVER HERE </div>

Comments