]> BookStack Code Mirror - bookstack/blob - app/Activity.php
Added basic system tests for markdown editor, Added extra test helpers
[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      */
19     public function entity()
20     {
21         if ($this->entity_type === '') $this->entity_type = null;
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('BookStack\User');
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         return [$this->key, $this->entitiy_type, $this->entitiy_id] === [$activityB->key, $activityB->entitiy_type, $activityB->entitiy_id];
50     }
51
52 }