Support the ongoing development of Laravel.io →
Database Eloquent

If I use the following code snippet in my model it inserts the data:

$fillable = ['email', 'username']; 
$instance = DB::table('users')->insert(compact('email', 'username'));

But if I do this instead:

$fillable = ['email', 'username']; 
$instance = static::create(compact('email', 'username'));

It inserts null, but created_at and updated_at are inserted.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Pkallesoe pkallesoe Joined 5 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.