diff --git a/content/system/classes/Notifications/DatabaseNotification.php b/content/system/classes/Notifications/DatabaseNotification.php new file mode 100644 index 000000000..b08cc1f8a --- /dev/null +++ b/content/system/classes/Notifications/DatabaseNotification.php @@ -0,0 +1,10 @@ +morphMany(DatabaseNotification::class, 'notifiable')->orderBy('created_at', 'desc'); + } + +} \ No newline at end of file diff --git a/content/system/classes/Notifications/Timestamp.php b/content/system/classes/Notifications/Timestamp.php new file mode 100644 index 000000000..034925822 --- /dev/null +++ b/content/system/classes/Notifications/Timestamp.php @@ -0,0 +1,41 @@ +changeTimeZone($raw_time, '', config('system.timezone')); + } + + public function getUpdatedAtAttribute($raw_time) + { + return $this->changeTimeZone($raw_time, '', config('system.timezone')); + } + + public function changeTimeZone($dateString, $timeZoneSource = null, $timeZoneTarget = null) + { + + if (empty($timeZoneSource)) { + $timeZoneSource = date_default_timezone_get(); + } + if (empty($timeZoneTarget)) { + $timeZoneTarget = date_default_timezone_get(); + } + + try { + $dt = new \DateTime($dateString, new \DateTimeZone($timeZoneSource)); + $dt->setTimezone(new \DateTimeZone($timeZoneTarget)); + return $dt->format('Y-m-d H:i:s'); + } catch (\Exception $e) { + ecjia_log_error($e->getMessage()); + } + + return $dateString; + } + +} \ No newline at end of file diff --git a/content/system/classes/admin/ecjia_admin_notifiable.class.php b/content/system/classes/admin/ecjia_admin_notifiable.class.php index 1d0c4fde3..254292ec5 100644 --- a/content/system/classes/admin/ecjia_admin_notifiable.class.php +++ b/content/system/classes/admin/ecjia_admin_notifiable.class.php @@ -44,13 +44,10 @@ // // --------------------------------------------------------------------------------- // -use Royalcms\Component\Notifications\Notifiable; -use Royalcms\Component\Database\Eloquent\Model; +use Ecjia\System\Notifications\NotifiableModel; -class ecjia_admin_notifiable extends Model +class ecjia_admin_notifiable extends NotifiableModel { - use Notifiable; - /** * The table associated with the model. *