0

I'm trying to show an HTML containing variables if a condition was met, else just show "test" word.

<a href="/StuffSpot/notifPost/{{ $notification->id }}">{{ $notification->read == 1 ? '<strong>{{$notification->send_uname}}</strong> has commented on <strong>{{$notification->title}}</strong> post' : 'test' }}</a> 

I'm receiving the following error :

Parse error: syntax error, unexpected '}', expecting ',' or ')'

Regolith
  • 2,867
  • 9
  • 31
  • 47
Abdallah Sakre
  • 865
  • 1
  • 6
  • 19
  • Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – treyBake Aug 02 '19 at 08:04

1 Answers1

1
<a href="/StuffSpot/notifPost/{{ $notification->id }}">
    @if($notification->read == 1)
        <strong> {{ $notification->send_uname }}</strong> has commented on <strong>{{ $notification->title }}</strong> post
    @else
        test
    @endif
 </a>

Try if else instead of one line Ternary Logic.

Also you have already used {{ }} to echo out, dont use {{ }} inside another, to display the html tags use {!! !!}, laravel blade {{ }} will escape and echo out the html tags inside these field

Regolith
  • 2,867
  • 9
  • 31
  • 47