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://*.com/questions/34565515/laravel-5-massassignmentexception-in-model-php