5 use Illuminate\Database\Eloquent\Model;
7 class Entity extends Model
10 * Relation for the user that created this entity.
11 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
13 public function createdBy()
15 return $this->belongsTo('Oxbow\User', 'created_by');
19 * Relation for the user that updated this entity.
20 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
22 public function updatedBy()
24 return $this->belongsTo('Oxbow\User', 'updated_by');
28 * Compares this entity to another given entity.
29 * Matches by comparing class and id.
33 public function matches($entity)
35 return [get_class($this), $this->id] === [get_class($entity), $entity->id];
39 * Gets the activity for this entity.
40 * @return \Illuminate\Database\Eloquent\Relations\MorphMany
42 public function activity()
44 return $this->morphMany('Oxbow\Activity', 'entity')->orderBy('created_at', 'desc');
48 * Gets only the most recent activity
53 public function recentActivity($limit = 20, $page=0)
55 return $this->activity()->skip($limit*$page)->take($limit)->get();