1
0
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:
Dan Brown
2015-08-16 18:59:23 +01:00
parent 41eb2fb633
commit 5d9d096028
19 changed files with 673 additions and 251 deletions

View File

@ -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();
}
}