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 * Allows checking of the exact class, Used to check entity type.
49 * Cleaner method for is_a.
53 public function isA($type)
55 return $this->getName() === strtolower($type);
58 public function getName()
60 $fullClassName = get_class($this);
61 return strtolower(array_slice(explode('\\', $fullClassName), -1, 1)[0]);