久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='I5qDA'></tfoot>
    <i id='I5qDA'><tr id='I5qDA'><dt id='I5qDA'><q id='I5qDA'><span id='I5qDA'><b id='I5qDA'><form id='I5qDA'><ins id='I5qDA'></ins><ul id='I5qDA'></ul><sub id='I5qDA'></sub></form><legend id='I5qDA'></legend><bdo id='I5qDA'><pre id='I5qDA'><center id='I5qDA'></center></pre></bdo></b><th id='I5qDA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='I5qDA'><tfoot id='I5qDA'></tfoot><dl id='I5qDA'><fieldset id='I5qDA'></fieldset></dl></div>
      <bdo id='I5qDA'></bdo><ul id='I5qDA'></ul>
    1. <small id='I5qDA'></small><noframes id='I5qDA'>

      <legend id='I5qDA'><style id='I5qDA'><dir id='I5qDA'><q id='I5qDA'></q></dir></style></legend>

        在 Laravel 中創建一個可鏈接的方法

        creating a chainable method in laravel(在 Laravel 中創建一個可鏈接的方法)
          1. <i id='9oaDK'><tr id='9oaDK'><dt id='9oaDK'><q id='9oaDK'><span id='9oaDK'><b id='9oaDK'><form id='9oaDK'><ins id='9oaDK'></ins><ul id='9oaDK'></ul><sub id='9oaDK'></sub></form><legend id='9oaDK'></legend><bdo id='9oaDK'><pre id='9oaDK'><center id='9oaDK'></center></pre></bdo></b><th id='9oaDK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9oaDK'><tfoot id='9oaDK'></tfoot><dl id='9oaDK'><fieldset id='9oaDK'></fieldset></dl></div>

            • <legend id='9oaDK'><style id='9oaDK'><dir id='9oaDK'><q id='9oaDK'></q></dir></style></legend>

              <small id='9oaDK'></small><noframes id='9oaDK'>

                <tfoot id='9oaDK'></tfoot>

                  <tbody id='9oaDK'></tbody>
                  <bdo id='9oaDK'></bdo><ul id='9oaDK'></ul>
                  本文介紹了在 Laravel 中創建一個可鏈接的方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我一直在嘗試在 laravel' eloquent 中創建我自己的可鏈接方法,但我遺漏了一些東西并且不確定是什么.這聽起來可能有點瘋狂,但請查看下面我的函數,以更好地了解我想說的內容.

                  I have been trying to create my own chainable method in laravel' eloquent but I'm missing something and not sure what. This may sound a little bit nuts but have a look at my function below to get a better idea of what I'm trying to say.

                  class Post extends Eloquent{
                      public static function custom_wh($data){
                          return static::where_in('categories_id', $data, 'AND');
                      }
                  }
                  
                  //this works fine
                  $posts = Post::custom_wh(array(1, 2, 3))->get();
                  
                  //but this says custom_wh is not defined in the query class
                  $posts = Post::where_in('tags', array(2, 3, 4), 'AND')->custom_wh(array(1, 2, 3))->get();
                  

                  如果我理解正確,那么我的方法沒有資格在另一個方法之后鏈接?所以我想我的問題是如何在我的模型中創建一個可鏈接的方法?

                  if I understand correctly then my method is not eligible to chain after another method? So I guess my question is how can I create a chainable method in my model?

                  PS 我已經查看了 laravel 的查詢構建器類,在那里我看到可鏈接的方法返回該對象的實例,但除了我在代碼中完成的方式之外,我找不到返回該對象的方法多于.任何形式的建議或建議都非常感謝.提前致謝.

                  P.S I have looked into the laravel's query builder class where I have seen that the chainable methods returns the instance of that object but I couldn't find a way to return the object other than the way I've done in the code above. Any kind of suggestion or advice is highly appreciated. Thanks in advance.

                  推薦答案

                  您可以在 Laravel 中使用查詢范圍"來做到這一點.您可以在此處找到文檔.

                  You can do that in Laravel with the "query scopes". You can find the doc here.

                  你只需要寫一個帶有前綴scope的函數,你就可以像其他查詢構建器一樣鏈接這個方法:

                  You just have to write a function with the prefix scope and you will be able to chain this method like the other query builder ones :

                  class Post extends Eloquent {
                  
                      public function scopeWhereCategories($query, $categories)
                      {
                          return $query->whereIn('categories_id', $categories, 'AND');
                      }
                  
                  }
                  
                  $posts = Post::whereCategories([1, 2, 3])->get();
                  $posts = Post::orderBy('date')->whereCategories([1, 2, 3])->take(5)->get();
                  

                  這篇關于在 Laravel 中創建一個可鏈接的方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                    <i id='Bkn3w'><tr id='Bkn3w'><dt id='Bkn3w'><q id='Bkn3w'><span id='Bkn3w'><b id='Bkn3w'><form id='Bkn3w'><ins id='Bkn3w'></ins><ul id='Bkn3w'></ul><sub id='Bkn3w'></sub></form><legend id='Bkn3w'></legend><bdo id='Bkn3w'><pre id='Bkn3w'><center id='Bkn3w'></center></pre></bdo></b><th id='Bkn3w'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Bkn3w'><tfoot id='Bkn3w'></tfoot><dl id='Bkn3w'><fieldset id='Bkn3w'></fieldset></dl></div>
                    • <bdo id='Bkn3w'></bdo><ul id='Bkn3w'></ul>

                      <legend id='Bkn3w'><style id='Bkn3w'><dir id='Bkn3w'><q id='Bkn3w'></q></dir></style></legend>
                          <tbody id='Bkn3w'></tbody>

                          1. <tfoot id='Bkn3w'></tfoot>

                            <small id='Bkn3w'></small><noframes id='Bkn3w'>

                            主站蜘蛛池模板: 国产日韩欧美精品一区二区 | 一级大黄| 毛片.com| 午夜精品一区二区三区在线观看 | 中文字幕一区在线观看视频 | 国产天天操 | 91偷拍精品一区二区三区 | 日韩欧美一级精品久久 | 欧美一级欧美一级在线播放 | 欧美一区二区三区在线播放 | 国产又爽又黄的视频 | 在线观看免费毛片 | 成人一区二区三区 | 免费观看av网站 | 久久爱综合| 新疆少妇videos高潮 | 精品久久成人 | 伊人免费视频二 | 99综合在线 | 九一精品 | 干出白浆视频 | 亚洲国产一区二区三区 | 国产99免费| 免费观看黄色一级片 | 欧美日韩久久久 | 一级黄在线观看 | 欧美一级在线免费观看 | 视频在线观看亚洲 | 中文久久 | 97久久久久久 | 久久久国产视频 | 国产精品久久一区二区三区 | 激情国产视频 | 99草免费视频 | 真人毛片 | 激情伊人网 | 国产免费看 | 久久精品二区 | 伊人精品在线 | 高清黄色 | 日日操夜夜操天天操 |