drtsd7864 2018-07-24 20:08
浏览 134
已采纳

单击搜索按钮后,为什么会出现分页错误?

I have a page "https://proj.test/user/profile?user=2#myRegistrations" where I have two tabs, one tab show the past registrations of a user in conferences and other tab the next registrations of the user in a conference. The user can click "Past Registrations" to check the past registrations and click in "Next Registrations" to check his next registrations in conferences. And its working.

In this same page, above the tabs, I have a form for the user to search for a conference name where he his registered. But when the user enters some text in the form search input like "test" and click in "Search" it appears "Undefined property: Illuminate\Pagination\LengthAwarePaginator::$participants (View: /Users/john/projects/proj/resources/views/users/index.blade.php)". Do you know what can be the issue?

Code in he view:

<div class="tab-pane clearfix fade" id="myTickets" role="tabpanel" aria-labelledby="contact-tab">
    <div class="d-flex justify-content-between">

        <form method="get" class="clearfix  w-75" method="POST" action="{{ route('user.searchRegistration') }}">
            {{ csrf_field() }}
            <div class="form-group col col-md-6 px-0">
                <div class="input-group" data-provide="datepicker">
                    <input type='text' class="form-control" placeholder="Search Registrations"
                           name="search_registration"
                           value="{{old('search_registration')}}"/>
                    <button class="input-group-addon">Search</button>
                </div>
            </div>
        </form>
        <a href="{{route('user.cleanSearchRegistration')}}" class="btn btn-outline-primary"
           id="cleanSearchRegistration">Clean Search</a>
    </div>

    @if(session('searchedRegistrations'))
        @if(session('searchedRegistrations')->count() != null)
            @foreach(session('searchedRegistrations') as $registration)
                @foreach(session('searchedRegistrations')->participants as $participant)
                    @if(!empty($registration))
                        <li class="list-group-item">
                            <h5>{{optional($registration->conference)->name}}</h5>

                            @if ($registration->status == 'C')
                                <a href="{{route('conference.registrationInfo',
                                    ['id' => $registration->conference->id,
                                    'slug' => $registration->conference->slug,
                                    'regID'=> $registration->id])}}"
                                   class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Registration document
                                </a>
                            @endif
                            @if ($participant->registration_type->certificate_available == 'Y')
                                <a href="{{route('conferences.certificateInfo',
                                    [
                                    'regID'=> $registration->id])}}"
                                   class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Download certificate
                                </a>
                                @break
                            @endif
                        </li>
                    @endif
                @endforeach
            @endforeach
            <div class="text-center d-flex justify-content-center mt-3">
                {{session('searchedRegistrations')->fragment('searchRegistrations')->links("pagination::bootstrap-4")}}
            </div>
        @else
            <div class="alert alert-info" role="alert">
                <i class="material-icons">info</i>
                <span>Your search didnt return any result.</span>
            </div>
        @endif
    @else
        <div class="d-flex mb-3">
            <ul class="nav nav-pills">
                <li class="nav-item">
                    <a class="nav-link active border" href="#nextConferences" data-toggle="tab" role="tab">Next
                        Conferences</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link border" href="#PastRegistrations" data-toggle="tab" role="tab">Past
                        Conferences</a>
                </li>
            </ul>
        </div>

        <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active clearfix" id="nextConferences" role="tabpanel"
                 aria-labelledby="home-tab">

                <ul class="list-group">
                    @foreach($nextRegistrations as $nextRegistration)
                        @foreach($nextRegistration->participants as $participant)
                            @if(!empty($nextRegistration->conference) || !empty($nextRegistration->conference->start_date))
                                <li class="list-group-item">
                                    <h5>{{optional($nextRegistration->conference)->name}}</h5>

                                    @if ($participant->registration_type->certificate_available == 'Y')
                                        <a href="{{route('conferences.certificateInfo',
                                    [
                                    'regID'=> $nextRegistration->id])}}"
                                           class="btn btn-primary ml-2"><i
                                                    class="fa fa-file-pdf-o"></i> Download Certificate</a>
                                        @break
                                    @endif

                                    @if ($nextRegistration->status == 'C')
                                        <a href="{{route('conferences.registrationInfo',
                                    [
                                    'regID'=> $nextRegistration->id])}}"
                                           class="btn btn-primary ml-2"><i
                                                    class="fa fa-file-pdf-o"></i> Registration document
                                        </a>
                                    @endif
                                </li>
                            @endif
                        @endforeach
                    @endforeach
                </ul>
                <div class="text-center d-flex justify-content-center mt-3">
                    {{$nextRegistrations->fragment('nextConferences')->links("pagination::bootstrap-4")}}
                </div>
            </div>

            <div class="tab-pane fade show clearfix" id="pastConferences" role="tabpanel" aria-labelledby="home-tab">

                <ul class="list-group">
                    @foreach($pastRegistrations as $pastRegistration)
                        @foreach($pastRegistration->participants as $participant)
                            @if(!empty($pastRegistration->conference) || !empty($pastRegistration->conference->start_date))
                                <li class="list-group-item">
                                    <h5>{{optional($pastRegistration->conference)->name}}</h5>
                                    @if ($participant->registration_type->certificate_available == 'Y')
                                        <a href="{{route('conferences.certificateInfo',['regID'=> $pastRegistration->id])}}"
                                           class="btn btn-primary ml-2"><i
                                                    class="fa fa-file-pdf-o"></i> Download Certificate
                                        </a>
                                        @break
                                    @endif
                                    @if ($pastRegistration->status == 'C')
                                        <a href="{{route('conferences.registrationInfo',
                                    [
                                    'regID'=> $pastRegistration->id])}}"
                                           class="btn btn-primary ml-2"><i
                                                    class="fa fa-file-pdf-o"></i> Registration info
                                        </a>
                                    @endif
                                </li>
                            @endif
                        @endforeach
                    @endforeach
                </ul>
                <div class="text-center d-flex justify-content-center mt-3">
                    {{$pastRegistrations->fragment('pastConferences')->links("pagination::bootstrap-4")}}
                </div>
            </div>
        </div>
</div>
  • 写回答

1条回答 默认 最新

  • doudengjin8251 2018-07-24 20:14
    关注

    I assume session('searchedRegistrations') is the Pagination instance. There is no property named participants nor would there be any random properties (it is a container, not what it contains). I would imagine a model instance contained in the collection might have a participants property though.

    @foreach(session('searchedRegistrations') as $registration)
        @foreach(session('searchedRegistrations')->participants as $participant)
    

    I am guessing that should be

        @foreach($registration->participants as $participant)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛