mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Added activity history to to all entities. Fixes #12
This commit is contained in:
@ -34,4 +34,25 @@ class Entity extends Model
|
||||
{
|
||||
return [get_class($this), $this->id] === [get_class($entity), $entity->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the activity for this entity.
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function activity()
|
||||
{
|
||||
return $this->morphMany('Oxbow\Activity', 'entity')->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the most recent activity
|
||||
* @param int $limit
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
*/
|
||||
public function recentActivity($limit = 20, $page=0)
|
||||
{
|
||||
return $this->activity()->skip($limit*$page)->take($limit)->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user