传递值时,它表示未定义的变量

时间:2017-03-24 05:07:54

标签: php laravel laravel-5.3

以下是我在@ layouts.master中调用的@include:

      <li id="alert_notificatoin_bar" class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="   
                         {{url('/admin/notification')}}">
                        <i class="icon-bell-l"></i>


                        <span class="badge bg-important">{{ $users}}</span>


                    </a>
                    <ul class="dropdown-menu extended notification">
                        <div class="notify-arrow notify-arrow-blue"></div>
                        <li>
                            <p class="blue">You have  notifications</p>
                        </li>


                        <li>
                            <a href="{{url('/admin/notificationshow')}}">
                             @foreach($users1 as $u)
                                <span class="label label-success"><i class="icon_like"></i></span> 
                                {{$u->name}}
                                <span class="small italic pull-right"> {{$u->created_at}}</span>
                                 @endforeach;
                            </a>
                        </li>   

                        <li>
                            <a href="#">See all notifications</a>
                        </li>

                    </ul>
                </li>

这是我的控制器

    public function notification()
    {
    $users = DB::table('users')->where("Active", 0)->count();
     $users1 = DB::table('users')->where("Active", 0)->get();

    return view('admin.layout.master')->with('users',$users)->with('users1',$users1);

    //return view('');
     }

    public function notificationshow()
     {

        $users1 = DB::table('users')->where("Active", 0)->get();

       return view('admin.dashboard.notificationshow')->with('users1',$users1);


      }


         public function updatenotification(Request $request)
     {
     DB::table('users')
        ->where($request)
        ->update(['Active' => 1]);
      return view('admin.dashboard.notificationshow');
     }
     }

这是我的另一个获取错误通知的视图

        <div class="row">
         <div class="col-lg-12">


           <div> 
                    @foreach($users1 as $u)
                   <span class="label label-success"><i class="icon_like"></i>
                   {{$u->name}}</span>
                   <span class="small italic pull-right"><label> <h5>Requested at</h5></label>{{$u-   
                    >created_at}}</span>
                   <label><h5>Waiting for Approval</h5></label>
                   @endforeach
                   <form class="login-form" role="form" method="POST" action="{{ url('/admin/')    
                 }}">
                        {{ csrf_field() }} 

            <button class="btn btn-primary btn-lg btn-block" type="submit">Approve</button>
                </div>
            </form>

为什么它给我错误请帮助我使用dd($ user1)检查;它给出了值但是为什么我在其他视图通知中传递值时会出现错误

1 个答案:

答案 0 :(得分:0)

这是一种代码整洁,特别是缩进,可以帮助您识别代码中的错误的情况。查看上面提供的代码,有不匹配的<div><form>标记,以及可能导致错误的奇怪位置的换行符。