Jeff Winkler
Jeff Winkler

Reputation: 147

Database not adding all fields

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]

Upvotes: 0

Views: 83

Answers (1)

Mozammil
Mozammil

Reputation: 8750

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'];

Upvotes: 3

Related Questions