语法错误,laravel中出现意外的'else'(t_else)

jtoj6r0c  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(378)

这个问题在这里已经有答案了

php解析/语法错误;以及如何解决这些问题(18个答案)
两年前关门了。
我是一个编程和laravel的初学者,我对我的代码/项目有一些问题。我想一个条件,我的主网页菜单只能由身份验证用户访问,但我有一个错误时,使条件在代码中。请帮我解决这个问题

  • 英语不好很抱歉

这里是风景

<!DOCTYPE html>
<html lang="en">
<head>
  <title>DOKO MOTOR</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="{{url('/')}}/css/lwd.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div id="top-header" style="background:#FFF;height: 100px;"s>
<div id="header" class="hidden-sm hidden-xs">
  <img src="{{url('/')}}/img/logo.png" height="90px" style="position: absolute;">
  <div class="bendera"></div>
              <div class="hotline pull-right">
                  <div class="left"><i class="glyphicon glyphicon-earphone" style="
    font-size: 50px; color:red;
"></i></div>
                    <div class="right">
                    <div class="r-top">hotline :</div>
                        <div class="r-bot">0896 5200 6229</div>
                    </div>
                    <div class="break"></div>
                </div><!-- /.hotline -->
                <div class="top-wel pull-right">Selamat datang di website kami, Jumat, 11 Mei 2018 </div>
</div><!-- /#header -->

</div>

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="{{ url("") }}">DOKO MOTOR</a>
    </div>
    <ul class="nav navbar-nav">
      <!-- @if(Auth::user()) -->
      @if(Auth::user())
      <li class="{{ request()->is('book') ? 'active' : '' }}"><a href="{{ url("book") }}"><span class="glyphicon glyphicon-wrench"></span> Book Service</a></li>
      <!-- @endif -->
      <li class="{{ request()->is('services') ? 'active' : '' }}"><a href="{{ url("services") }}"><span class="glyphicon glyphicon-hourglass"></span> Antrian Service</a></li>
      <li class="{{ request()->is('contact') ? 'active' : '' }}"><a href="{{ url("contact") }}"><span class="glyphicon glyphicon-user"></span> Kontak</a></li>
      <li class="{{ request()->is('tentang') ? 'active' : '' }}"><a href="{{ url("tentang") }}"><span class="glyphicon glyphicon-earphone"></span> Tentang</a></li>

    </ul>
    <ul class="nav navbar-nav navbar-right">
      <!-- @if(Auth::user()) --> 
      <li><a href="{{URL::to('/logout')}}">
      <span style="color: blue"> {{ ucwords(Auth::user()->name) }}</span> <span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
      <!-- @else -->
      @else

      <li><a href="{{URL::to('/register')}}"><span class="glyphicon glyphicon-user"></span> Daftar</a></li>
      <li><a href="{{URL::to('/signin')}}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      <!-- @endif -->
      @endif
    </ul>
  </div>
</nav>

<div class="container">
  @yield('content')
</div>

<div id="footer">

        <div class="row">
          <div class="col-md-12">
              <div class="copy">Copyright © 2018 -  All rights reserved.</div>
            </div>
        </div><!-- /.row -->
</div>
</body>
</html>

这是路线

Route::get('/signin', function() {
    return view('login');
});

Route::get('/register/{date?}', function($date = null) {
    return view('register',['date',$date]);
});

Route::post('/register_action/{date?}','RegisterController@store');

Route::post('/login_check','RegisterController@login');

Route::get('logout', function() {
    Auth::logout();

    return Redirect::to('');
})->middleware("auth");

Route::get('/', function(){
    if( auth()->check() ){
        return Redirect::to('/');
    }else{
        return Redirect::to('/auth');   
    }
});

Route::get('/', 'HomeController@index');

Route::get('/contact','ContactController@index');

Route::get('/tentang','TentangController@index');

Route::get('/book/{date?}', 'ServisController@book');

Route::get('/services/{add?}', 'ServisController@services');

Route::post('/submit_book', 'ServisController@submit_book'); 

Route::post('/update_service', 'ServisController@update_service'); 

Route::post('/delete_service', 'ServisController@delete_service');

错误消息
如果有什么能帮到我,我会很感激的
谨致问候

fwzugrvs

fwzugrvs1#

尝试更改html的结构方式:

@if(Auth::user())
<ul class="nav navbar-nav">
  <li class="{{ request()->is('book') ? 'active' : '' }}"><a href="{{ url("book") }}"><span class="glyphicon glyphicon-wrench"></span> Book Service</a></li>
  <li class="{{ request()->is('services') ? 'active' : '' }}"><a href="{{ url("services") }}"><span class="glyphicon glyphicon-hourglass"></span> Antrian Service</a></li>
  <li class="{{ request()->is('contact') ? 'active' : '' }}"><a href="{{ url("contact") }}"><span class="glyphicon glyphicon-user"></span> Kontak</a></li>
  <li class="{{ request()->is('tentang') ? 'active' : '' }}"><a href="{{ url("tentang") }}"><span class="glyphicon glyphicon-earphone"></span> Tentang</a></li>
</ul>
@endif
<ul class="nav navbar-nav navbar-right">
  @if(Auth::user())
  <li><a href="{{URL::to('/logout')}}">
  <span style="color: blue"> {{ ucwords(Auth::user()->name) }}</span> <span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
  @else
  <li><a href="{{URL::to('/register')}}"><span class="glyphicon glyphicon-user"></span> Daftar</a></li>
  <li><a href="{{URL::to('/signin')}}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
  @endif
</ul>

在if语句之后,编写html的方式必须是有意义的,要将其可视化,请尝试删除某个情况会创建的代码,因此,如果用户不在,请删除该代码并查看剩下的内容,此时您将拥有没有意义的html,浏览器将无法以您希望的方式显示它

相关问题