I want only use created_at , how to do it?
I know:
This can custom timestamps name
JavaScript
x
const CREATED_AT = 'created';
const UPDATED_AT = 'updated';
This can disable timestamps
JavaScript
public $timestamps = false;
Advertisement
Answer
Eloquent does not provide such functionality out of the box, but you can create it on your own using the creating
event callback:
JavaScript
class User extends Eloquent {
public $timestamps = false;
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->created_at = $model->freshTimestamp();
});
}
}