Home > OS >  Curly brackets {{}} is deleting my null value laravel
Curly brackets {{}} is deleting my null value laravel

Time:01-21

I am passing a variable that may be null value from controller to blade

When this variable is of a null value it causes an error in the following line where it says unexpected token,

'client_id': {{$current_client}},

enter image description here

Whats the correct syntax for this situation?

CodePudding user response:

Wrap this in back ticks i.e.

'client_id': `{{$current_client}}`

if there's a null value, it'll return empty not an error.

CodePudding user response:

Wrap the code in a single quote,

'client_id': '{{ $client_id }}'
  •  Tags:  
  • Related