From dd9a991dae8158f3abcb2b89dddb6377686e3a88 Mon Sep 17 00:00:00 2001 From: Chris Halbert Date: Wed, 22 Aug 2018 22:43:50 -0400 Subject: [PATCH] [GH-18-TimestampableTrait] Add timestampable trait. --- src/Traits/Timestampable.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Traits/Timestampable.php diff --git a/src/Traits/Timestampable.php b/src/Traits/Timestampable.php new file mode 100644 index 0000000..9167654 --- /dev/null +++ b/src/Traits/Timestampable.php @@ -0,0 +1,24 @@ +addHook(NomadicMigration::PRE_MIGRATE, function () use ($self) { + $self->set('started_at', Carbon::now()); + }); + $this->addHook(NomadicMigration::POST_MIGRATE, function () use ($self) { + $self->set('finished_at', Carbon::now()); + }); + } +}