]> BookStack Code Mirror - bookstack/blob - app/Actions/Activity.php
improve italian translation
[bookstack] / app / Actions / Activity.php
1 <?php
2
3 namespace BookStack\Actions;
4
5 use BookStack\Auth\User;
6 use BookStack\Entities\Entity;
7 use BookStack\Model;
8
9 /**
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
18  */
19 class Activity extends Model
20 {
21
22     /**
23      * Get the entity for this activity.
24      */
25     public function entity()
26     {
27         if ($this->entity_type === '') {
28             $this->entity_type = null;
29         }
30         return $this->morphTo('entity');
31     }
32
33     /**
34      * Get the user this activity relates to.
35      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
36      */
37     public function user()
38     {
39         return $this->belongsTo(User::class);
40     }
41
42     /**
43      * Returns text from the language files, Looks up by using the
44      * activity key.
45      */
46     public function getText()
47     {
48         return trans('activities.' . $this->key);
49     }
50
51     /**
52      * Checks if another Activity matches the general information of another.
53      * @param $activityB
54      * @return bool
55      */
56     public function isSimilarTo($activityB)
57     {
58         return [$this->key, $this->entity_type, $this->entity_id] === [$activityB->key, $activityB->entity_type, $activityB->entity_id];
59     }
60 }