Removing Timestamp Columns from Eloquent Models

May 9th, 2025 • 1 minute read time

If you want to exclude the created_at and updated_at columns from a table and disable them in your Eloquent models, here's how.

To start, ensure you've removed the created_at and updated_at columns from your migration.

public function up(): void
{
    Schema::create('releases', function (Blueprint $table) {
        $table->id();
        $table->foreignId('repo_id')->constrained();
        $table->string('tag_name');
        $table->string('name');
        $table->text('body');
        // $table->timestamps();
    });
}

I've commented it out here for demonstration, but it's best to remove it entirely.

Once you've done that and run your migrations, head to the model you're using and disable timestamps.

class Release extends Model
{
    /** @use HasFactory<\Database\Factories\ReleaseFactory> */
    use HasFactory;

    public $timestamps = false;
}

This ensures that Laravel doesn't fill in the created_at and updated_at dates when creating or updating a record.

And that's it! Remove the column, disable with a simple property in your model, and you're done!

If you found this article helpful, you'll love our practical screencasts.
Author
Alex Garrett-Smith
Share :

Comments

No comments, yet. Be the first!

Tagged under