3 namespace BookStack\Actions;
5 use BookStack\Auth\User;
6 use BookStack\Entities\Entity;
10 * @property string $key
11 * @property User $user
12 * @property Entity $entity
13 * @property string $extra
14 * @property string $entity_type
15 * @property int $entity_id
16 * @property int $user_id
17 * @property int $book_id
19 class Activity extends Model
23 * Get the entity for this activity.
25 public function entity()
27 if ($this->entity_type === '') {
28 $this->entity_type = null;
30 return $this->morphTo('entity');
34 * Get the user this activity relates to.
35 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
37 public function user()
39 return $this->belongsTo(User::class);
43 * Returns text from the language files, Looks up by using the
46 public function getText()
48 return trans('activities.' . $this->key);
52 * Checks if another Activity matches the general information of another.
56 public function isSimilarTo($activityB)
58 return [$this->key, $this->entity_type, $this->entity_id] === [$activityB->key, $activityB->entity_type, $activityB->entity_id];