diff --git a/framework/core/src/Core/Notifications/Notification.php b/framework/core/src/Core/Notifications/Notification.php index da5c4378a..9651756b1 100644 --- a/framework/core/src/Core/Notifications/Notification.php +++ b/framework/core/src/Core/Notifications/Notification.php @@ -1,7 +1,6 @@ mappedMorphTo(static::$subjectModels, 'subject', 'type', 'subject_id'); + return $this->morphTo('subject', 'subjectModel', 'subject_id'); } /** diff --git a/framework/core/src/Core/Notifications/NotificationRepository.php b/framework/core/src/Core/Notifications/NotificationRepository.php index 8977bea65..b19e2860a 100644 --- a/framework/core/src/Core/Notifications/NotificationRepository.php +++ b/framework/core/src/Core/Notifications/NotificationRepository.php @@ -26,8 +26,7 @@ class NotificationRepository ->skip($offset) ->take($limit); - return Notification::with('subject') - ->select('notifications.*', 'p.unread_count') + return Notification::select('notifications.*', 'p.unread_count') ->mergeBindings($primaries->getQuery()) ->join(app('flarum.db')->raw('('.$primaries->toSql().') p'), 'notifications.id', '=', 'p.id') ->latest('time') diff --git a/framework/core/src/Core/Support/MappedMorphTo.php b/framework/core/src/Core/Support/MappedMorphTo.php deleted file mode 100644 index d9579631a..000000000 --- a/framework/core/src/Core/Support/MappedMorphTo.php +++ /dev/null @@ -1,43 +0,0 @@ -map = $map; - - parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation); - } - - /** - * Create a new model instance by type. - * - * @param string $type - * @return \Illuminate\Database\Eloquent\Model - */ - public function createModelByType($type) - { - return new $this->map[$type]; - } -} diff --git a/framework/core/src/Core/Support/MappedMorphToTrait.php b/framework/core/src/Core/Support/MappedMorphToTrait.php deleted file mode 100644 index 3b21c0320..000000000 --- a/framework/core/src/Core/Support/MappedMorphToTrait.php +++ /dev/null @@ -1,48 +0,0 @@ -getMorphs($name, $type, $id); - - // If the type value is null it is probably safe to assume we're eager loading - // the relationship. When that is the case we will pass in a dummy query as - // there are multiple types in the morph and we can't use single queries. - if (is_null($typeValue = $this->$type)) { - return new MappedMorphTo( - $this->newQuery(), - $this, - $id, - null, - $type, - $name, - $classes - ); - } else { - // If we are not eager loading the relationship we will essentially treat this - // as a belongs-to style relationship since morph-to extends that class and - // we will pass in the appropriate values so that it behaves as expected. - $class = $classes[$typeValue]; - $instance = new $class; - - return new MappedMorphTo( - $instance->newQuery(), - $this, - $id, - $instance->getKeyName(), - $type, - $name, - $classes - ); - } - } -}