<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 將一個集合拆分2個集合 在 Laravel v5.3.27 之后,collection 新增了一個 partition 方法,該方法可以根據傳入的條件 將原來的 collection 分成兩個 collection,比如: ~~~ $collection = collect([1, 2, 3, 4, 5, 6, 7]); $items = $collection->partition(function ($item) { return $item < 4; }); ~~~ 這樣會得到下面的結果: ~~~ Collection {#190 ▼ #items: array:2 [▼ 0 => Collection {#183 ▼ #items: array:3 [▼ 0 => 1 1 => 2 2 => 3 ] } 1 => Collection {#189 ▼ #items: array:4 [▼ 3 => 4 4 => 5 5 => 6 6 => 7 ] } ] } ~~~ 結果返回的兩個都是 collection 對象。 # where方法 Laravel 5.3 開始,在 collection 層面也開始支持使用 where 方法,對于一些應用場景非常的適用: 比如在沒有 where 方法的使用,我們可能會使用 filter 方法來達到一定的目的: ~~~ $vips = $users->filter(function ($user) { return $user->role === 'vip'; }); ~~~ 但是在 5.3 中,你可以直接這樣使用: ~~~ $vips = $users->where('role', 'vip'); ~~~ Nice and clean ! 更甚至的是,你還可以傳入比較符號,如 >, < 等: ~~~ $members = $users->where('role', '!==', 'vip'); $expert = $users->where('experience', '>', 500); ~~~ where 方法無疑是為 collection 添加了更方便的過濾和查找方法,希望大家在這樣的場景之下可以用起來。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看