Ronnel Dela Peña
Ronnel Dela Peña

Reputation: 41

How can I fix the problem in converting blade syntax to php? if statement in blade to php

I have my code supported by Blade syntax in resources\views which is working then there is an automated coded from laravel framework in storage\framework\views written in PHP.

Blade

enter image description here

PHP

enter image description here

I am expecting to get the same result from blade syntax, but I have a syntax error converting to PHP

Upvotes: 2

Views: 57

Answers (1)

Djellal Mohamed Aniss
Djellal Mohamed Aniss

Reputation: 1733

you're getting an error cause when you use a blade directive, you don't need to use {{ }} to get a variable value, so the right syntax is:

@if ( Auth::guard("employee")->check() )
...
@endif

one more thing, the check() method returns a boolean so you can't chain with the user() method. so what you need to do is

@if ( Auth::guard("employee")->check() )
  <p>welcome {{Auth::user()->name}} !<p>
@endif

Upvotes: 2

Related Questions