From d11fbd4287cad0bcc434a96740f3fdf338b0ef51 Mon Sep 17 00:00:00 2001 From: David Harting Date: Sat, 21 Dec 2024 14:30:16 -0500 Subject: [PATCH 1/2] fill in created_at/updated_at for media --- app/Actions/SofaImport/SofaRowHandler.php | 10 ++++++++++ app/Models/Media.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Actions/SofaImport/SofaRowHandler.php b/app/Actions/SofaImport/SofaRowHandler.php index 6595485..5ce10d3 100644 --- a/app/Actions/SofaImport/SofaRowHandler.php +++ b/app/Actions/SofaImport/SofaRowHandler.php @@ -37,6 +37,16 @@ private function handleMedia(): int $isNew = $this->media->wasRecentlyCreated; + // created_at and updated_at were not fillable before I ran this the first time. + // So update that so that media timestamps reflect when I added them to lists rather than current time + if (! $isNew) { + $this->media->update([ + 'updated_at' => $this->row->dateAdded, + 'created_at' => $this->row->dateAdded, + ]); + } + + // TODO: Add a note if the item already exists (i.e., was imported from goodreads without a note) if (! $isNew && ! is_null($this->row->notes)) { $this->media->note = $this->row->notes; diff --git a/app/Models/Media.php b/app/Models/Media.php index 2a8843d..053634b 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -11,7 +11,7 @@ class Media extends Model { use HasFactory; - protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id']; + protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id', 'created_at', 'updated_at']; // TODO: Add enum and cast for MediaType From c7ddab4366ff4d0f7609fbc6d74ebdb288dea795 Mon Sep 17 00:00:00 2001 From: David Harting Date: Sat, 21 Dec 2024 14:31:45 -0500 Subject: [PATCH 2/2] pint --- app/Actions/SofaImport/SofaRowHandler.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Actions/SofaImport/SofaRowHandler.php b/app/Actions/SofaImport/SofaRowHandler.php index 5ce10d3..27c8a10 100644 --- a/app/Actions/SofaImport/SofaRowHandler.php +++ b/app/Actions/SofaImport/SofaRowHandler.php @@ -46,7 +46,6 @@ private function handleMedia(): int ]); } - // TODO: Add a note if the item already exists (i.e., was imported from goodreads without a note) if (! $isNew && ! is_null($this->row->notes)) { $this->media->note = $this->row->notes;