mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Added view count tracking with personalised lists
This commit is contained in:
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
abstract class Entity extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Relation for the user that created this entity.
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@ -36,7 +37,7 @@ abstract class Entity extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the activity for this entity.
|
||||
* Gets the activity objects for this entity.
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function activity()
|
||||
@ -44,6 +45,24 @@ abstract class Entity extends Model
|
||||
return $this->morphMany('BookStack\Activity', 'entity')->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View objects for this entity.
|
||||
* @return mixed
|
||||
*/
|
||||
public function views()
|
||||
{
|
||||
return $this->morphMany('BookStack\View', 'viewable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get just the views for the current user.
|
||||
* @return mixed
|
||||
*/
|
||||
public function userViews()
|
||||
{
|
||||
return $this->views()->where('user_id', '=', auth()->user()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows checking of the exact class, Used to check entity type.
|
||||
* Cleaner method for is_a.
|
||||
|
Reference in New Issue
Block a user