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

<tfoot id='ptRY9'></tfoot>

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

          <bdo id='ptRY9'></bdo><ul id='ptRY9'></ul>

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

        為什么在調用 Eloquent 模型中的方法時出現“不應

        Why I#39;m getting #39;Non-static method should not be called statically#39; when invoking a method in a Eloquent model?(為什么在調用 Eloquent 模型中的方法時出現“不應靜態調用非靜態方法?) - IT屋-程序員軟件開發
          <bdo id='viZz1'></bdo><ul id='viZz1'></ul>
          <legend id='viZz1'><style id='viZz1'><dir id='viZz1'><q id='viZz1'></q></dir></style></legend>
            <i id='viZz1'><tr id='viZz1'><dt id='viZz1'><q id='viZz1'><span id='viZz1'><b id='viZz1'><form id='viZz1'><ins id='viZz1'></ins><ul id='viZz1'></ul><sub id='viZz1'></sub></form><legend id='viZz1'></legend><bdo id='viZz1'><pre id='viZz1'><center id='viZz1'></center></pre></bdo></b><th id='viZz1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='viZz1'><tfoot id='viZz1'></tfoot><dl id='viZz1'><fieldset id='viZz1'></fieldset></dl></div>

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

            <tfoot id='viZz1'></tfoot>

                    <tbody id='viZz1'></tbody>
                • 本文介紹了為什么在調用 Eloquent 模型中的方法時出現“不應靜態調用非靜態方法"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我試圖在我的控制器中加載我的模型并嘗試了這個:

                  Im trying to load my model in my controller and tried this:

                  return Post::getAll();
                  

                  得到錯誤 非靜態方法 Post::getAll() 不應靜態調用,假設 $this 來自不兼容的上下文

                  模型中的函數如下所示:

                  The function in the model looks like this:

                  public function getAll()
                  {
                  
                      return $posts = $this->all()->take(2)->get();
                  
                  }
                  

                  在控制器中加載模型然后返回其內容的正確方法是什么?

                  What's the correct way to load the model in a controller and then return it's contents?

                  推薦答案

                  您已將方法定義為非靜態方法,而您正試圖以靜態方式調用它.話說……

                  You defined your method as non-static and you are trying to invoke it as static. That said...

                  1.如果你想調用一個靜態方法,你應該使用::并將你的方法定義為靜態.

                  1.if you want to invoke a static method, you should use the :: and define your method as static.

                  // Defining a static method in a Foo class.
                  public static function getAll() { /* code */ }
                  
                  // Invoking that static method
                  Foo::getAll();
                  

                  2.否則,如果你想調用一個實例方法,你應該實例化你的類,使用->.

                  2.otherwise, if you want to invoke an instance method you should instance your class, use ->.

                  // Defining a non-static method in a Foo class.
                  public function getAll() { /* code */ }
                  
                  // Invoking that non-static method.
                  $foo = new Foo();
                  $foo->getAll();
                  

                  注意:在 Laravel 中,幾乎所有 Eloquent 方法都返回模型的一個實例,允許您按如下所示鏈接方法:

                  Note: In Laravel, almost all Eloquent methods return an instance of your model, allowing you to chain methods as shown below:

                  $foos = Foo::all()->take(10)->get();
                  

                  在該代碼中,我們通過 Facade 靜態調用 all 方法.之后,所有其他方法都被稱為實例方法.

                  In that code we are statically calling the all method via Facade. After that, all other methods are being called as instance methods.

                  這篇關于為什么在調用 Eloquent 模型中的方法時出現“不應靜態調用非靜態方法"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                • <tfoot id='MZNy7'></tfoot>
                    <tbody id='MZNy7'></tbody>

                  • <legend id='MZNy7'><style id='MZNy7'><dir id='MZNy7'><q id='MZNy7'></q></dir></style></legend>
                    <i id='MZNy7'><tr id='MZNy7'><dt id='MZNy7'><q id='MZNy7'><span id='MZNy7'><b id='MZNy7'><form id='MZNy7'><ins id='MZNy7'></ins><ul id='MZNy7'></ul><sub id='MZNy7'></sub></form><legend id='MZNy7'></legend><bdo id='MZNy7'><pre id='MZNy7'><center id='MZNy7'></center></pre></bdo></b><th id='MZNy7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MZNy7'><tfoot id='MZNy7'></tfoot><dl id='MZNy7'><fieldset id='MZNy7'></fieldset></dl></div>

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

                          <bdo id='MZNy7'></bdo><ul id='MZNy7'></ul>

                            主站蜘蛛池模板: 淫片一级国产 | 欧美视频免费在线 | 国产在线一区二 | 日韩av一区二区在线观看 | 久久精品免费一区二区 | 免费av观看| 成人免费一区二区 | xxxcom在线观看 | 在线视频一区二区 | 9999久久 | 国产黄色一级片 | 欧美一区二区视频 | 国产福利网站 | 91亚洲精选 | 精品在线播放 | 精品一区在线 | 在线观看中文字幕视频 | 亚洲网站在线观看 | 水蜜桃久久夜色精品一区 | 精品成人免费一区二区在线播放 | 亚洲情侣视频 | 国内精品成人 | 国产精品久久久久久久久免费丝袜 | 日韩欧美黄色 | 亚洲 欧美 综合 | av一区二区三区 | 国产精品久久久久久久久久免费 | 国产精品久久久久久婷婷天堂 | 国产亚洲精品精品国产亚洲综合 | 亚洲一区二区久久 | 日本久久久影视 | 国产精品国产成人国产三级 | 亚洲精品免费视频 | 亚洲一区二区在线播放 | 日韩午夜一区二区三区 | 久久久久久久97 | 国产良家自拍 | 久久国产成人精品国产成人亚洲 | 国产欧美精品一区二区 | 久久成人免费视频 | 51ⅴ精品国产91久久久久久 |