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

  • <tfoot id='l8Yq0'></tfoot>

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

  • <small id='l8Yq0'></small><noframes id='l8Yq0'>

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

      1. 什么是“批量分配"?在 Laravel 中是什么意思

        What does quot;Mass Assignmentquot; mean in Laravel?(什么是“批量分配?在 Laravel 中是什么意思?)
        <legend id='Xhweo'><style id='Xhweo'><dir id='Xhweo'><q id='Xhweo'></q></dir></style></legend>
          <bdo id='Xhweo'></bdo><ul id='Xhweo'></ul>

              <tbody id='Xhweo'></tbody>
              <tfoot id='Xhweo'></tfoot>
              1. <small id='Xhweo'></small><noframes id='Xhweo'>

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

                1. 本文介紹了什么是“批量分配"?在 Laravel 中是什么意思?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  當我瀏覽有關 Eloquent ORM 主題部分的 Laravel 文檔時,我得到了一個新術語批量分配".

                  When I went through Laravel Document about Eloquent ORM topic part, I got a new term "Mass Assignment".

                  文檔顯示如何進行批量分配和 $fillable$guarded 屬性設置.但是經歷了那之后,我對批量分配"并沒有清楚的了解.以及它是如何工作的.

                  Document show How to do Mass Assignment and the $fillable or $guarded properties settings. But after went through that, I didn't have a clearly understand about "Mass Assignment" and how it works.

                  在我過去使用 CodeIgniter 的經驗中,我也沒有聽說過這個術語.

                  In my past experience in CodeIgniter, I also didn't hear about this term.

                  有人對此有一個簡單的解釋嗎?

                  Does anyone have a simple explanation about that?

                  推薦答案

                  Mass assignment 是當你發送一個數組到模型創建時,基本上是一次性在模型上設置一堆字段,而不是一個一個,類似:

                  Mass assignment is when you send an array to the model creation, basically setting a bunch of fields on the model in a single go, rather than one by one, something like:

                  $user = new User(request()->all());
                  

                  (這不是分別在模型上顯式設置每個值.)

                  (This is instead of explicitly setting each value on the model separately.)

                  您可以使用 fillable 來保護您希望它實際允許更新的字段.

                  You can use fillable to protect which fields you want this to actually allow for updating.

                  您還可以通過執行以下操作阻止所有字段可批量分配:

                  You can also block all fields from being mass-assignable by doing this:

                  protected $guarded = ['*'];
                  

                  假設在您的用戶表中有一個字段是 user_type 并且可以具有 user/admin 的值

                  Let's say in your user table you have a field that is user_type and that can have values of user / admin

                  顯然,您不希望用戶能夠更新此值.理論上,如果您使用上述代碼,有人可以將 user_type 的新字段注入表單并將admin"與其他表單數據一起發送,然后輕松地將他們的帳戶切換到管理員帳戶... 壞消息.

                  Obviously, you don't want users to be able to update this value. In theory, if you used the above code, someone could inject into a form a new field for user_type and send 'admin' along with the other form data, and easily switch their account to an admin account... bad news.

                  通過添加:

                  $fillable = ['name', 'password', 'email'];
                  

                  您確保只有那些值可以使用 mass assignment

                  You are ensuring that only those values can be updated using mass assignment

                  為了能夠更新 user_type 值,您需要在模型上顯式設置并保存它,如下所示:

                  To be able to update the user_type value, you need to explicitly set it on the model and save it, like this:

                  $user->user_type = 'admin';
                  $user->save();
                  

                  這篇關于什么是“批量分配"?在 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 找不到驅動程序)

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

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

                    • <bdo id='eSDpT'></bdo><ul id='eSDpT'></ul>
                            <tfoot id='eSDpT'></tfoot>

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

                            主站蜘蛛池模板: 国产综合精品一区二区三区 | 免费国产成人av | 亚洲精品国产精品国自产在线 | 国产亚洲精品综合一区 | 国产精品激情小视频 | 国产视频精品在线 | 中文字幕在线视频精品 | 亚洲国产高清高潮精品美女 | 97伦理最新伦理 | 亚洲+变态+欧美+另类+精品 | 全免费a级毛片免费看视频免费下 | 国产区精品 | 国产精品中文在线 | 欧美精品久久久久久久久久 | 欧美精品片 | 国产中文字幕在线观看 | 在线视频 亚洲 | 国产欧美一级二级三级在线视频 | 日韩在线视频一区 | 黑人巨大精品欧美一区二区免费 | 黄网站在线播放 | 少妇黄色 | 综合久久av| 久久999| 九九亚洲 | 亚洲精品v日韩精品 | 精品一区在线免费观看 | 精品国产一区探花在线观看 | 日韩喷潮| 久久精品一区 | 91精品国产乱码久久久久久久久 | 看羞羞视频免费 | 亚洲综合色视频在线观看 | 91欧美精品 | 精品一区二区不卡 | 免费观看羞羞视频网站 | 国产精品久久久久久久久久久久午夜片 | 国产精品久久久久久福利一牛影视 | 精品日本久久久久久久久久 | 天天色综 | 久久综合国产 |