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