<bdo id='9ovkV'></bdo><ul id='9ovkV'></ul>

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

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

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

        Laravel 5:Model.php 中的 MassAssignmentException

        时间:2023-09-23

            <bdo id='lJUrz'></bdo><ul id='lJUrz'></ul>
          • <tfoot id='lJUrz'></tfoot>
              <tbody id='lJUrz'></tbody>

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

              • <legend id='lJUrz'><style id='lJUrz'><dir id='lJUrz'><q id='lJUrz'></q></dir></style></legend>
                <i id='lJUrz'><tr id='lJUrz'><dt id='lJUrz'><q id='lJUrz'><span id='lJUrz'><b id='lJUrz'><form id='lJUrz'><ins id='lJUrz'></ins><ul id='lJUrz'></ul><sub id='lJUrz'></sub></form><legend id='lJUrz'></legend><bdo id='lJUrz'><pre id='lJUrz'><center id='lJUrz'></center></pre></bdo></b><th id='lJUrz'></th></span></q></dt></tr></i><div id='lJUrz'><tfoot id='lJUrz'></tfoot><dl id='lJUrz'><fieldset id='lJUrz'></fieldset></dl></div>
                  本文介绍了Laravel 5:Model.php 中的 MassAssignmentException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我收到此错误:

                  Model.php 第 448 行中的 MassAssignmentException:_token

                  MassAssignmentException in Model.php line 448: _token

                  当我使用 create 方法时.请查看以下代码:

                  When I am using create method. Please review code below:

                  Contacts.php(模型):

                  class Contacts extends Model
                  {
                      protected $table = ['name', 'mobile', 'email', 'address', 'created_at', 'updated_at'];
                  }
                  

                  ContactsController.php(控制器):

                  public function store(Request $request)
                  {        
                      $inputs = $request->all();
                      $contacts = Contacts::Create($inputs);
                      return redirect()->route('contacts.index');
                  }
                  

                  推荐答案

                  对于 Mass Assignment例外:您应该通过对属性$fillable 的创建或更新操作来指定您想要批量分配的模型的所有字段:

                  For the Mass Assignment Exception: you should specify all the fields of the model that you want to be mass-assignable through create or update operations on the property $fillable:

                  protected $fillable = ['name', 'mobile', 'email', 'address', 'created_at', 'updated_at'];
                  

                  此外,$table 字段应该只包含模型的表名:

                  Besides, the field $table should contain only the model's table name:

                  protected $table = 'your_table_name';
                  

                  这篇关于Laravel 5:Model.php 中的 MassAssignmentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Laravel 在同一个表中返回父母的孩子 下一篇:在 Laravel Eloquent 中检索所有 morphedByMany 关系

                  相关文章

                  最新文章

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

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

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

                    2. <legend id='vIn6v'><style id='vIn6v'><dir id='vIn6v'><q id='vIn6v'></q></dir></style></legend>

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