mirror of
https://github.com/flarum/core.git
synced 2025-10-18 10:16:09 +02:00
Use morphTo instead of mappedMorphTo
Turns out we don't need MappedMorphTo after all.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php namespace Flarum\Core\Notifications;
|
||||
|
||||
use Flarum\Core\Model;
|
||||
use Flarum\Core\Support\MappedMorphToTrait;
|
||||
|
||||
/**
|
||||
* Models a notification record in the database.
|
||||
@@ -21,8 +20,6 @@ use Flarum\Core\Support\MappedMorphToTrait;
|
||||
*/
|
||||
class Notification extends Model
|
||||
{
|
||||
use MappedMorphToTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -114,7 +111,7 @@ class Notification extends Model
|
||||
*/
|
||||
public function subject()
|
||||
{
|
||||
return $this->mappedMorphTo(static::$subjectModels, 'subject', 'type', 'subject_id');
|
||||
return $this->morphTo('subject', 'subjectModel', 'subject_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user