+ * Gets the activity objects for this entity.
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ public function activity()
+ {
+ return $this->morphMany(Activity::class, 'entity')->orderBy('created_at', 'desc');
+ }
+
+ /**
+ * Get View objects for this entity.
+ */
+ public function views()
+ {
+ return $this->morphMany(View::class, 'viewable');
+ }
+
+ /**
+ * Get the Tag models that have been user assigned to this entity.
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ public function tags()
+ {
+ return $this->morphMany(Tag::class, 'entity')->orderBy('order', 'asc');
+ }
+
+ /**
+ * Get the related search terms.
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ public function searchTerms()
+ {
+ return $this->morphMany(SearchTerm::class, 'entity');
+ }
+
+ /**
+ * Get this entities restrictions.
+ */
+ public function permissions()
+ {
+ return $this->morphMany(EntityPermission::class, 'restrictable');
+ }
+
+ /**
+ * Check if this entity has a specific restriction set against it.
+ * @param $role_id
+ * @param $action