简体   繁体   中英

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

在此处输入图片说明

PHP

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM