earmsby's avatar

missing columns when adding Filament relation

I have a Model: Account and a Model: AccountNote. Account has a relationship:

public function accountNotes(): HasMany
    {
        return $this->hasMany(AccountNote::class);
    }

And AccountNote has this relationship:

public function account(): BelongsTo
    {
        return $this->belongsTo(Account::class);
    }

In my filament resource for Account, I have a relation manager for AccountNotes. The table and view work fine but when I try to add a new AccountNote from the relation manager, I'm getting a SQl error:

ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (Connection: mysql, SQL: insert into `account_notes` (`note_text`, `added_by`, `note_date`, `account_id`, `updated_at`, `created_at`) values (Here is another note, 1, 2026-03-26 15:41:07, 48, 2026-03-26 15:41:07, 2026-03-26 15:41:07)) {"userId":1,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (Connection: mysql, SQL: insert into `account_notes` (`note_text`, `added_by`, `note_date`, `account_id`, `updated_at`, `created_at`) values (Here is another note, 1, 2026-03-26 15:41:07, 48, 2026-03-26 15:41:07, 2026-03-26 15:41:07))

The table for AccountNotes does not have the usual timestamp fields because they aren't necessary. Am I understanding the error correctly that Filament is expecting these fields to exist anyway? Is there a way to solve this without adding unnecessary fields to the table?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Absolutely, you’ve diagnosed the problem correctly. Filament (or rather, Eloquent, which Filament relies on) automatically assumes your models have created_at and updated_at columns unless you specifically tell it not to. When Filament tries to create or update an AccountNote, Eloquent tries to insert values for those columns, hence the SQL error because they don’t actually exist in your account_notes table.

Solution:
You just need to tell Eloquent that your AccountNote model does not use timestamps by setting the $timestamps property to false. Add this property to your AccountNote model:

class AccountNote extends Model
{
    public $timestamps = false;

    // ...your relationships and other code
}

With this, Eloquent (and thus Filament) will stop trying to use created_at and updated_at, and your insert will work.


Summary of steps:

  1. Open your AccountNote model.
  2. Add:
    public $timestamps = false;
    
  3. Enjoy not needing to add unnecessary timestamp columns to your table!

Reference: Eloquent: Timestamps Documentation

Please or to participate in this conversation.