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

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

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

    1. <legend id='OpJh1'><style id='OpJh1'><dir id='OpJh1'><q id='OpJh1'></q></dir></style></legend>

      <tfoot id='OpJh1'></tfoot>

        • <bdo id='OpJh1'></bdo><ul id='OpJh1'></ul>

      1. 擴展/覆蓋 Eloquent 創建方法 - 不能使靜態方法非靜

        Extend/override Eloquent create method - Cannot make static method non static(擴展/覆蓋 Eloquent 創建方法 - 不能使靜態方法非靜態)
          <tbody id='0XOuY'></tbody>

        • <bdo id='0XOuY'></bdo><ul id='0XOuY'></ul>

          <small id='0XOuY'></small><noframes id='0XOuY'>

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

                <legend id='0XOuY'><style id='0XOuY'><dir id='0XOuY'><q id='0XOuY'></q></dir></style></legend>
                  本文介紹了擴展/覆蓋 Eloquent 創建方法 - 不能使靜態方法非靜態的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我覆蓋了 create() Eloquent 方法,但是當我嘗試調用它時,我得到 Cannot make static method Illuminate\Database\Eloquent\Model::create() 類 MyModel 中的非靜態.

                  I'm overriding the create() Eloquent method, but when I try to call it I get Cannot make static method Illuminate\Database\Eloquent\Model::create() non static in class MyModel.

                  我像這樣調用 create() 方法:

                  I call the create() method like this:

                  $f = new MyModel();
                  $f->create([
                      'post_type_id' => 1,
                      'to_user_id' => Input::get('toUser'),
                      'from_user_id' => 10,
                      'message' => Input::get('message')
                  ]);
                  

                  MyModel 類中,我有這個:

                  And in the MyModel class I have this:

                  public function create($data) {
                      if (!NamespaceAuth::isAuthed())
                          throw new Exception("You can not create a post as a guest.");
                  
                      parent::create($data);
                  }
                  

                  為什么這不起作用?我應該改變什么才能讓它工作?

                  Why doesn't this work? What should I change to make it work?

                  推薦答案

                  正如錯誤所說:IlluminateDatabaseEloquentModel::create() 方法是靜態的,不能被重寫為非靜態.

                  As the error says: The method IlluminateDatabaseEloquentModel::create() is static and cannot be overridden as non-static.

                  所以實現它

                  class MyModel extends Model
                  {
                      public static function create($data)
                      {
                          // ....
                      }
                  }
                  

                  并通過 MyModel::create([...]);

                  您也可以重新考慮 auth-check-logic 是否真的是模型的一部分,或者更好地將其移至控制器或路由部分.

                  You may also rethink if the auth-check-logic is really part of the Model or better moving it to the Controller or Routing part.

                  更新

                  這種方法從 5.4.* 版本開始不起作用,而是按照 這個答案.

                  This approach does not work from version 5.4.* onwards, instead follow this answer.

                  public static function create(array $attributes = [])
                  {
                      $model = static::query()->create($attributes);
                  
                      // ...
                  
                      return $model;
                  }
                  

                  這篇關于擴展/覆蓋 Eloquent 創建方法 - 不能使靜態方法非靜態的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                  <legend id='s3yQl'><style id='s3yQl'><dir id='s3yQl'><q id='s3yQl'></q></dir></style></legend>
                        <tbody id='s3yQl'></tbody>

                    1. <small id='s3yQl'></small><noframes id='s3yQl'>

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

                          <tfoot id='s3yQl'></tfoot>
                          • <bdo id='s3yQl'></bdo><ul id='s3yQl'></ul>
                            主站蜘蛛池模板: 国产精品人人做人人爽 | 亚洲综合色自拍一区 | 亚洲第一网站 | 免费视频二区 | 午夜视频在线观看网址 | 国产精品亚洲精品久久 | 小草久久久久久久久爱六 | 日韩精品在线一区 | 国产精品久久久久久妇女6080 | 国产在线观看一区二区三区 | 国产精品日产欧美久久久久 | 国产精品久久久久久久7777 | 九九热久久免费视频 | 欧美一级二级三级 | 国产日韩欧美 | 免费观看一级毛片视频 | 日韩一区在线视频 | 欧美精品网站 | 九九久久精品视频 | 伊人网在线看 | 日韩一区二区三区视频在线观看 | 欧美激情在线观看一区二区三区 | h视频在线观看免费 | 色悠悠久 | 午夜电影一区二区 | 国产精品毛片一区二区在线看 | 日韩免费视频 | 精品一区在线免费观看 | 欧美一级片在线看 | 亚洲精品成人av久久 | 亚洲日韩中文字幕一区 | 日韩高清三区 | 国产激情在线观看视频 | 欧美精品综合在线 | 日韩欧美专区 | 岛国午夜| 99国内精品久久久久久久 | 久久久久久久久久爱 | 成人做爰www免费看视频网站 | 久久一区 | 日韩中文字幕在线播放 |