亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在頁面中顯示兩次拉維爾分頁鏈接

在頁面中顯示兩次拉維爾分頁鏈接

PHP
慕容森 2022-09-17 17:39:51
我在我的一個項目中實現了一個拉拉維爾分頁,其中分頁像一個魅力一樣工作。我要求在表的頂部和表的底部顯示分頁鏈接。喜歡這個{!! $entries->render() !!}<table class="table table-responsive" id="entries-table">    <thead>        <tr>                <th>ID</th>                <th>Advisor name</th>        </tr>    </thead>    <tbody>    @forelse($entries as $entries)        <tr>            <td> {{ $entries->id }} </td>            <td> {{ $entries->name }} </td>        </tr>    @empty    <tr>        <td>            <p>No record found.</p>        </td>    </tr>    @endforelse    </tbody></table>{!! $entries->render() !!}當我嘗試在表格底部或同一頁面的任何地方再使用一次時,它會給我帶來以下錯誤。{!! $entries->render() !!}錯誤異常 (E_ERROR) 調用未定義的方法 應用程序\模型\條目::render()這是我的控制器代碼public function index(Request $request)    {                    $entries = Entries::orderBy('id', 'DESC')->paginate(15);        return view('entries.index')            ->with('entries', $entries);    }在這里,我正在使用控制器轉儲變體,這就是我得到的。$entriesdd($entries)LengthAwarePaginator {#425 ▼  #total: 215  #lastPage: 15  #items: Collection {#436 ▼    #items: array:15 [▼      0 => entries {#437 ?}      1 => entries {#438 ?}      2 => entries {#439 ?}      3 => entries {#440 ?}      4 => entries {#441 ?}      5 => entries {#442 ?}      6 => entries {#443 ?}      7 => entries {#444 ?}      8 => entries {#445 ?}      9 => entries {#446 ?}      10 => entries {#447 ?}      11 => entries {#448 ?}      12 => entries {#449 ?}      13 => entries {#450 ?}      14 => entries {#451 ?}    ]  }  #perPage: 15  #currentPage: 1  #path: "https://samplesite.com/entries/11"  #query: []  #fragment: null  #pageName: "page"  +onEachSide: 3  #options: array:2 [▼    "path" => "https://samplesite.com/entries/11"    "pageName" => "page"  ]}查看此視頻,我與您分享以獲得更好的想法
查看完整描述

4 回答

?
撒科打諢

TA貢獻1934條經驗 獲得超2個贊

您不應該在前言上的變量中給出相同的名稱,這可能會導致.errors之間的沖突,這可能是因為變量的abigu來自雄辯的結果或循環中的結果。


嘗試像這樣重構你的代碼


@forelse($entries as $entrie)

    <tr>

        <td> {{ $entrie->id }} </td>

        <td> {{ $entrie->name }} </td>

    </tr>

@empty

<tr>

    <td>

        <p>No record found.</p>

    </td>

</tr>

@endforelse


查看完整回答
反對 回復 2022-09-17
?
滄海一幻覺

TA貢獻1824條經驗 獲得超5個贊

您正在用 中的集合項覆蓋集合。$entries@forelse


@forelse($entries as $entries)

    <tr>

        <td> {{ $entries->id }} </td>

        <td> {{ $entries->name }} </td>

    </tr>

@empty

更改為 :$entries$entry


@forelse($entries as $entry)

    <tr>

        <td> {{ $entry->id }} </td>

        <td> {{ $entry->name }} </td>

    </tr>

@empty


查看完整回答
反對 回復 2022-09-17
?
瀟瀟雨雨

TA貢獻1833條經驗 獲得超4個贊

確保在邊欄選項卡中返回確切的集合。


$users= User::paginate(15);


return view('entries', compact('users'));

并且您已經可以在刀片中使用此行。


{!! $entries->links() !!}


{!! $users->render() !!}

也在你的為每個,把它改成這個


@forelse($entries as $entry)

     <tr>

         <td> {{ $entry->id }} </td>

         <td> {{ $entry->name }} </td>

     </tr>

@empty

嘗試將控制器更改為此。


  public function index(Request $request)

    {            

            $entries = entries::where('form_id', '=', $id)->orderBy('id', 'DESC')->paginate(15);


            return view('entries.index')

                ->with('entries', $entries);

    }


查看完整回答
反對 回復 2022-09-17
?
慕俠2389804

TA貢獻1719條經驗 獲得超6個贊

你試過嗎?{{ $entries->links() }}

更新

在你的控制器中,你可以試試這個

    $users = User::paginate(1);  
    dd($users->links(), $users->links());

你有同樣的錯誤嗎?


查看完整回答
反對 回復 2022-09-17
  • 4 回答
  • 0 關注
  • 153 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號