mirror of
https://github.com/flarum/core.git
synced 2025-08-17 13:54:18 +02:00
Revert notifications_from table
I didn't think this change through and it's going to be too difficult to implement right now. It can wait until we do the notifications revamp. For now reverting back to the old structure, with the `sender_id` column renamed to `from_user_id`.
This commit is contained in:
@@ -49,7 +49,7 @@ class Notification extends AbstractModel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['created_at', 'read_at', 'deleted_at'];
|
||||
protected $dates = ['created_at', 'read_at'];
|
||||
|
||||
/**
|
||||
* A map of notification types and the model classes to use for their
|
||||
@@ -112,7 +112,7 @@ class Notification extends AbstractModel
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ class Notification extends AbstractModel
|
||||
*/
|
||||
public function sender()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'sender_id');
|
||||
return $this->belongsTo(User::class, 'from_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ class Notification extends AbstractModel
|
||||
*/
|
||||
public function subject()
|
||||
{
|
||||
return $this->morphTo('subject', 'subjectModel', 'subject_id');
|
||||
return $this->morphTo('subject', 'subjectModel');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,7 +32,7 @@ class NotificationRepository
|
||||
)
|
||||
->where('user_id', $user->id)
|
||||
->whereIn('type', $user->getAlertableNotificationTypes())
|
||||
->whereNull('deleted_at')
|
||||
->where('is_deleted', false)
|
||||
->groupBy('type', 'subject_id')
|
||||
->orderByRaw('MAX(created_at) DESC')
|
||||
->skip($offset)
|
||||
|
@@ -225,10 +225,10 @@ class NotificationSyncer
|
||||
protected function getAttributes(Blueprint\BlueprintInterface $blueprint)
|
||||
{
|
||||
return [
|
||||
'type' => $blueprint::getType(),
|
||||
'sender_id' => ($sender = $blueprint->getSender()) ? $sender->id : null,
|
||||
'type' => $blueprint::getType(),
|
||||
'from_user_id' => ($sender = $blueprint->getSender()) ? $sender->id : null,
|
||||
'subject_id' => ($subject = $blueprint->getSubject()) ? $subject->id : null,
|
||||
'data' => ($data = $blueprint->getData()) ? json_encode($data) : null
|
||||
'data' => ($data = $blueprint->getData()) ? json_encode($data) : null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -435,7 +435,7 @@ class User extends AbstractModel
|
||||
$cached = $this->notifications()
|
||||
->whereIn('type', $this->getAlertableNotificationTypes())
|
||||
->whereNull('read_at')
|
||||
->whereNull('deleted_at')
|
||||
->where('is_deleted', false)
|
||||
->get();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user