]> BookStack Code Mirror - bookstack/blob - app/Activity.php
Update all.blade.php
[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 === '') {
20             $this->entity_type = null;
21         }
22         return $this->morphTo('entity');
23     }
24
25     /**
26      * Get the user this activity relates to.
27      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
28      */
29     public function user()
30     {
31         return $this->belongsTo(User::class);
32     }
33
34     /**
35      * Returns text from the language files, Looks up by using the
36      * activity key.
37      */
38     public function getText()
39     {
40         return trans('activities.' . $this->key);
41     }
42
43     /**
44      * Checks if another Activity matches the general information of another.
45      * @param $activityB
46      * @return bool
47      */
48     public function isSimilarTo($activityB)
49     {
50         return [$this->key, $this->entity_type, $this->entity_id] === [$activityB->key, $activityB->entity_type, $activityB->entity_id];
51     }
52 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.