1
0
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:
Toby Zerner
2015-08-04 17:33:58 +09:30
parent 854e131ef1
commit 667fe56947
4 changed files with 2 additions and 97 deletions

View File

@@ -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');
}
/**

View File

@@ -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')