-2

I have a rather complicated if-else statement and I need help.

I just want to check if there is a value in the Session and if yes, ouput a string called "alert-important", that is going to function as a hook for changes in the future.

The part that does not work is the second part with the if-statement.

<div class="alert alert-{{ Session::get('flash_notification.level') . ' worksfine ' . if(Session::has('flash_notification.important') ? 'alert-important' : '') }} ">

I get the error

"syntax error, unexpected 'if' (T_IF)"
LoveAndHappiness
  • 9,735
  • 21
  • 72
  • 106

2 Answers2

1

This would be ternary so it should be

(Session::has('flash_notification.important') ? 'alert-important' : '')

Es0teric
  • 26
  • 1
1

It looks like this statement is the offender

if(Session::has('flash_notification.important')

Shorthand if/else statements don't use the if keyword. This is the correct way:

(Session::has('flash_notification.important')

Dallin
  • 1,075
  • 13
  • 28