X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5d9d09602842bf98f56d274b720d5090f2e8acf0..refs/pull/846/head:/app/Activity.php diff --git a/app/Activity.php b/app/Activity.php index 64dd23518..c01da1f6c 100644 --- a/app/Activity.php +++ b/app/Activity.php @@ -1,29 +1,34 @@ entity_id) { - return $this->morphTo('entity')->first(); - } else { - return false; + if ($this->entity_type === '') { + $this->entity_type = null; } + return $this->morphTo('entity'); } + /** + * Get the user this activity relates to. + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function user() { - return $this->belongsTo('Oxbow\User'); + return $this->belongsTo(User::class); } /** @@ -35,4 +40,13 @@ class Activity extends Model return trans('activities.' . $this->key); } + /** + * Checks if another Activity matches the general information of another. + * @param $activityB + * @return bool + */ + public function isSimilarTo($activityB) + { + return [$this->key, $this->entity_type, $this->entity_id] === [$activityB->key, $activityB->entity_type, $activityB->entity_id]; + } }