Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Notifynder/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Notification extends Model
'extra' => 'array',
];

protected $notifiedModelInstance;
/**
* Notification constructor.
*
Expand All @@ -72,6 +73,10 @@ public function __construct($attributes = [])
}

parent::__construct($attributes);


$notifiedModel= notifynder_config()->getNotifiedModel();
$this->notifiedModelInstance = new $notifiedModel;
}

/**
Expand All @@ -87,11 +92,13 @@ public function category()
*/
public function from()
{


if (notifynder_config()->isPolymorphic()) {
return $this->morphTo('from');
}

return $this->belongsTo(notifynder_config()->getNotifiedModel(), 'from_id');
return $this->belongsTo(notifynder_config()->getNotifiedModel(), 'from_id', $this->notifiedModelInstance->getKeyName());
}

/**
Expand All @@ -103,7 +110,7 @@ public function to()
return $this->morphTo('to');
}

return $this->belongsTo(notifynder_config()->getNotifiedModel(), 'to_id');
return $this->belongsTo(notifynder_config()->getNotifiedModel(), 'to_id', $this->notifiedModelInstance->getKeyName());
}

/**
Expand Down