PHP高级工程师|全栈工程师|WX: Aben_Ring

Lavavel 程序报错 MassAssignmentException in Model.php line 452: _token

Lavarel 用类似于下面命令插入数据时候出错

Comment::create($request->all())

错误页面截图如下:

错误原因:下面这行代码应该写到对应的Model里面,而不是对应的Controller里面

protected $fillable = ['nickname', 'email', 'website', 'content', 'article_id'];
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    protected $fillable = ['nickname', 'email', 'website', 'content', 'article_id'];
}

资料参考:

http://stackoverflow.com/questions/34565515/laravel-5-massassignmentexception-in-model-php

 

posted @ 2016-07-27 18:31  懒牛拉车  阅读(5207)  评论(0编辑  收藏  举报