设置分页(在第2页中找不到数据)

时间:2018-06-07 06:13:28

标签: database laravel pagination

我正致力于在laravel中使用分页搜索数据。

问题:当我只搜索数据库中的第一个数据时就是结果 然后其他数据对另一页不可见。当我分页时,我的意思是看不到的。我想要的输出必须如下:

示例输出必须是

在第1页。

待定

在第2页。

待定

在第3页。

批准

我的路线:

Route::get('/previllage/searchapplication','ApplicantViewerController@searchapplication');

我的控制器:

public function searchapplication(Request $request)
{


    $search_button = $request->input('action');
    $status = $request->input('status');


    if(isset($search_button))
    {
      if($status == '')
      {
        //return redirect()->back();
      }
      else
      {
         $usersapplication_search = DB::table('onlineapplication')
          ->where('Status','like','%' . $status . '%')
          ->orWhere('firstname','like','%' . $status . '%')
            ->paginate(1);
             return View('/previllage/applicantviewer')
          ->with('usersapplication_search',$usersapplication_search);
      }

    }



}   

我的HTML

<div class="wrap-listaccount">
        <h4>Applicant</h4>
        <div class="row">
            <form action="/previllage/searchapplication" method="get">
                {{csrf_field()}}
                <div class="input-field col s12 m4 l4">
                  <input placeholder="Search User" required="" name="status" id="user" type="text" class="validate">
                  <label for="first_name"></label>
                  <input class="btn waves-effect waves-light red darken-4 btn-small" id="button-update" type="submit" value="Search" name="action">
                </div>
            </form>
        </div>
        <ul class="collection with-header">
            <li class="collection-item" style="background-color:#800000; color:white;">Application Status
            </li>
        </ul>
    <div class="table-container">       
        <table class="highlight">
            <thead>
              <tr>
                  <th>Position Id</th>
                  <th>Status</th>
                  <th>Email</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Middle Name</th>
                  <th>Starting Date</th>
                  <th>Home Number</th>
                  <th>Phone Number</th>
                  <th>File</th>
                  <th>Applicant Info</th>
              </tr>
            </thead>

                <tbody>

                    @if(isset($usersapplication_search))
                        @foreach($usersapplication_search  as $user)
                            <tr>
                                <td>{{$user->Status}}</td>
                            </tr>
                        @endforeach

                    @endif

                </tbody>
        </table>
       @if(isset($usersapplication_search))
        {{ $usersapplication_search->links() }}
       @endif
    </div>

    </div>

我这里有示例输出: sample out when i paginate to page2

0 个答案:

没有答案