]> BookStack Code Mirror - bookstack/blob - app/Activity.php
Found the source of the issue, not sure how to fix
[bookstack] / app / Activity.php
1 <?php
2
3 namespace BookStack;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 /**
8  * @property string  key
9  * @property \User   user
10  * @property \Entity entity
11  * @property string  extra
12  */
13 class Activity extends Model
14 {
15
16     /**
17      * Get the entity for this activity.
18      * @return bool
19      */
20     public function entity()
21     {
22         if ($this->entity_id) {
23             return $this->morphTo('entity')->first();
24         } else {
25             return false;
26         }
27     }
28
29     /**
30      * Get the user this activity relates to.
31      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
32      */
33     public function user()
34     {
35         return $this->belongsTo('BookStack\User');
36     }
37
38     /**
39      * Returns text from the language files, Looks up by using the
40      * activity key.
41      */
42     public function getText()
43     {
44         return trans('activities.' . $this->key);
45     }
46
47     /**
48      * Checks if another Activity matches the general information of another.
49      * @param $activityB
50      * @return bool
51      */
52     public function isSimilarTo($activityB) {
53         return [$this->key, $this->entitiy_type, $this->entitiy_id] === [$activityB->key, $activityB->entitiy_type, $activityB->entitiy_id];
54     }
55
56 }