douaoj0994 2017-05-03 06:00
浏览 58
已采纳

数据库未添加所有字段

I'm adding data to a DB table and some of the data is going in and some is not. I've recheck the field names to make sure they are correct.

The result of dd($request) is below:

[results of dd]

Controller:

    public function store(Request $request)
{
    //

    Donation::create($request->all());
    return redirect()->action('DonationController@index');
}

[Database results]

  • 写回答

1条回答 默认 最新

  • dongpalou5352 2017-05-03 06:09
    关注

    Laravel has a security mechanism whereby you need to specifically define which fields you want to allow to be filled, in this case mass assignable. More info here

    So in this case, in your Donation model, please ensure that the fields have been defined in the $fillable array as such

    protected $fillable = ['notes', 'another_field', 'another_field_2'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部