2015-08-16 19:59:23 +02:00
|
|
|
<?php
|
|
|
|
|
2015-09-10 20:31:09 +02:00
|
|
|
namespace BookStack;
|
2015-08-16 19:59:23 +02:00
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
/**
|
2015-08-30 12:47:58 +02:00
|
|
|
* @property string key
|
|
|
|
* @property \User user
|
2015-08-16 19:59:23 +02:00
|
|
|
* @property \Entity entity
|
2015-08-30 12:47:58 +02:00
|
|
|
* @property string extra
|
2015-08-16 19:59:23 +02:00
|
|
|
*/
|
|
|
|
class Activity extends Model
|
|
|
|
{
|
2015-08-30 12:47:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the entity for this activity.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2015-08-16 19:59:23 +02:00
|
|
|
public function entity()
|
|
|
|
{
|
2016-02-28 20:03:04 +01:00
|
|
|
return $this->morphTo('entity');
|
2015-08-16 19:59:23 +02:00
|
|
|
}
|
|
|
|
|
2015-08-30 12:47:58 +02:00
|
|
|
/**
|
|
|
|
* Get the user this activity relates to.
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2015-08-16 19:59:23 +02:00
|
|
|
public function user()
|
|
|
|
{
|
2015-09-10 20:31:09 +02:00
|
|
|
return $this->belongsTo('BookStack\User');
|
2015-08-16 19:59:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns text from the language files, Looks up by using the
|
|
|
|
* activity key.
|
|
|
|
*/
|
|
|
|
public function getText()
|
|
|
|
{
|
|
|
|
return trans('activities.' . $this->key);
|
|
|
|
}
|
|
|
|
|
2015-08-30 12:47:58 +02:00
|
|
|
/**
|
|
|
|
* Checks if another Activity matches the general information of another.
|
|
|
|
* @param $activityB
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isSimilarTo($activityB) {
|
|
|
|
return [$this->key, $this->entitiy_type, $this->entitiy_id] === [$activityB->key, $activityB->entitiy_type, $activityB->entitiy_id];
|
|
|
|
}
|
|
|
|
|
2015-08-16 19:59:23 +02:00
|
|
|
}
|