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

aGreenCoder's avatar

Create anchor tag with route contain under @php script in blade template

Route not working. how can I write an anchor tag, based on some condition? if the condition is true then the anchor tag will be printed with the route, I write the below code But I get an error.

In my blade template

@php
    if($p->name== 0){
    echo '<a href="{{ route('my.route') }}">Approve</a>';
    }	
@endphp
0 likes
1 reply
aGreenCoder's avatar
aGreenCoder
OP
Best Answer
Level 1

I get The solution I write here for future developer

@php
    if($p->cmpApprovalSA == 0){
    echo "<a href=".route('emp.data.view').">sdf</a>";
    }
@endphp
1 like

Please or to participate in this conversation.