Toni Toni - 1 year ago 142
PHP Question

laravel eloquent inserts empty record to database

Am using Laravel Eloquent

to insert record, but it inserts and empty record having values in only the id and timestamps.

$data['fname'] = $request->input('fname');
$data['lname'] = $request->input('lname');
$data['email'] = $request->input('email');
$data['phone'] = $request->input('phone');

Then in my
models I have

protected $fillable = array('fname, lname, email,phone');
public $timestamps = false;

It runs without error, but it inserts empty record to db. Can anybody help?

jah jah
Answer Source

Fillable is an array of strings, so each field, should be on its own index like:

protected $fillable = array('first_name', 'last_name', 'email');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download