3 namespace BookStack\Actions;
5 use BookStack\Auth\User;
6 use BookStack\Entities\Entity;
8 use Illuminate\Database\Eloquent\Relations\BelongsTo;
11 * @property string $type
12 * @property User $user
13 * @property Entity $entity
14 * @property string $detail
15 * @property string $entity_type
16 * @property int $entity_id
17 * @property int $user_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.
36 public function user(): BelongsTo
38 return $this->belongsTo(User::class);
42 * Returns text from the language files, Looks up by using the activity key.
44 public function getText(): string
46 return trans('activities.' . $this->type);
50 * Checks if another Activity matches the general information of another.
52 public function isSimilarTo(Activity $activityB): bool
54 return [$this->type, $this->entity_type, $this->entity_id] === [$activityB->type, $activityB->entity_type, $activityB->entity_id];