From 82d61e757fa61aeccb53b61574738f15665a5365 Mon Sep 17 00:00:00 2001 From: kusowl Date: Mon, 16 Feb 2026 12:27:30 +0530 Subject: [PATCH] fix: schema so that created_at uses current timestamp --- app/Models/Message.php | 7 ++++++- .../migrations/2026_02_11_052318_create_messages_table.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Models/Message.php b/app/Models/Message.php index 22425dc..ad41f43 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -17,6 +17,7 @@ * @property \Illuminate\Support\Carbon $created_at * @property-read \App\Models\Inbox|null $inbox * @property-read \App\Models\User|null $user + * * @method static \Illuminate\Database\Eloquent\Builder|Message newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Message newQuery() * @method static \Illuminate\Database\Eloquent\Builder|Message query() @@ -29,15 +30,19 @@ * @method static \Illuminate\Database\Eloquent\Builder|Message whereMessage($value) * @method static \Illuminate\Database\Eloquent\Builder|Message whereReadAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Message whereUserId($value) + * * @mixin \Eloquent */ class Message extends Model { + public $timestamps = false; + protected $fillable = [ 'inbox_id', 'user_id', 'message', 'read_at', 'deleted_at', 'failed_at', - 'created_at', 'delivered_at' + 'created_at', 'delivered_at', ]; + public function inbox(): BelongsTo { return $this->belongsTo(Inbox::class); diff --git a/database/migrations/2026_02_11_052318_create_messages_table.php b/database/migrations/2026_02_11_052318_create_messages_table.php index 5d7fa44..685c679 100644 --- a/database/migrations/2026_02_11_052318_create_messages_table.php +++ b/database/migrations/2026_02_11_052318_create_messages_table.php @@ -22,7 +22,7 @@ public function up(): void $table->time('delivered_at')->nullable(); $table->time('deleted_at')->nullable(); $table->time('failed_at')->nullable(); - $table->time('created_at')->useCurrent()->index(); + $table->timestamp('created_at')->useCurrent()->index(); }); }