]> BookStack Code Mirror - bookstack/blob - app/Activity.php
Merge pull request #3 from OsmosysSoftware/revert-1-issue-181
[bookstack] / app / Activity.php
1 <?php
2
3 namespace BookStack;
4
5 /**
6  * @property string  key
7  * @property \User   user
8  * @property \Entity entity
9  * @property string  extra
10  */
11 class Activity extends Model
12 {
13
14     /**
15      * Get the entity for this activity.
16      */
17     public function entity()
18     {
19         if ($this->entity_type === '') $this->entity_type = null;
20         return $this->morphTo('entity');
21     }
22
23     /**
24      * Get the user this activity relates to.
25      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
26      */
27     public function user()
28     {
29         return $this->belongsTo(User::class);
30     }
31
32     /**
33      * Returns text from the language files, Looks up by using the
34      * activity key.
35      */
36     public function getText()
37     {
38         return trans('activities.' . $this->key);
39     }
40
41     /**
42      * Checks if another Activity matches the general information of another.
43      * @param $activityB
44      * @return bool
45      */
46     public function isSimilarTo($activityB) {
47         return [$this->key, $this->entity_type, $this->entity_id] === [$activityB->key, $activityB->entity_type, $activityB->entity_id];
48     }
49
50 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.