<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國際加速解決方案。 廣告
                ## 根據關聯條件查詢 在取得模型數據時,您可能想要以關聯模型作為查詢限制。例如,您可能想要取得所有「至少有一篇評論」的Blog 文章。可以使用 has 方法達成目的: ~~~ $posts = Post::has('comments')->get(); ~~~ 也可以指定運算符和數量: ~~~ $posts = Post::has('comments', '>=', 3)->get(); ~~~ 也可以使用"點號"的形式來獲取嵌套的 has 聲明: ~~~ $posts = Post::has('comments.votes')->get(); ~~~ 如果想要更進階的用法,可以使用 whereHas 和 orWhereHas 方法,在 has 查詢里設置 "where" 條件 : ~~~ $posts = Post::whereHas('comments', function($q) { $q->where('content', 'like', 'foo%'); })->get(); ~~~ ## 動態屬性 Eloquent 可以經由動態屬性取得關聯對象。 Eloquent 會自動進行關聯查詢,而且會很聰明的知道應該要使用 get(用在一對多關聯)或是 first (用在一對一關聯)方法。可以經由和「關聯方法名稱相同」的動態屬性取得對象。例如,如下面的模型對象 $phone: ~~~ class Phone extends Model { public function user() { return $this->belongsTo('App\User'); } } $phone = Phone::find(1); ~~~ 您可以不用像下面這樣打印用戶的 email : ~~~ echo $phone->user()->first()->email; ~~~ 而可以簡寫如下: ~~~ echo $phone->user->email; ~~~ > 注意: 若取得的是許多關聯對象,會返回 Illuminate\Database\Eloquent\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>

                              哎呀哎呀视频在线观看