diff --git a/app/Models/Component.php b/app/Models/Component.php index 783d426d7..3d898afb2 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -134,6 +134,16 @@ class Component extends Model implements HasPresenter return $this->hasMany(Incident::class, 'component_id', 'id'); } + /** + * Get all of the meta relation. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function meta() + { + return $this->morphMany(Meta::class, 'meta'); + } + /** * Get the tags relation. * diff --git a/app/Models/Incident.php b/app/Models/Incident.php index 1816f850a..93b4be67f 100644 --- a/app/Models/Incident.php +++ b/app/Models/Incident.php @@ -145,7 +145,10 @@ class Incident extends Model implements HasPresenter * * @var string[] */ - protected $with = ['updates']; + protected $with = [ + 'meta', + 'updates', + ]; /** * Get the component relation. @@ -157,6 +160,16 @@ class Incident extends Model implements HasPresenter return $this->belongsTo(Component::class, 'component_id', 'id'); } + /** + * Get all of the meta relation. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function meta() + { + return $this->morphMany(Meta::class, 'meta'); + } + /** * Get the updates relation. * diff --git a/app/Models/Metric.php b/app/Models/Metric.php index ce3a6f466..a126ab374 100644 --- a/app/Models/Metric.php +++ b/app/Models/Metric.php @@ -165,6 +165,16 @@ class Metric extends Model implements HasPresenter }); } + /** + * Get all of the meta relation. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function meta() + { + return $this->morphMany(Meta::class, 'meta'); + } + /** * Get the points relation. * diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 3154c4e9d..020c15059 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -131,6 +131,26 @@ class Schedule extends Model implements HasPresenter */ protected $with = ['components']; + /** + * Get the components relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function components() + { + return $this->hasMany(ScheduleComponent::class); + } + + /** + * Get all of the meta relation. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function meta() + { + return $this->morphMany(Meta::class, 'meta'); + } + /** * Scopes schedules to those in the future. * @@ -155,16 +175,6 @@ class Schedule extends Model implements HasPresenter return $query->where('status', '<', self::COMPLETE)->where('scheduled_at', '<=', Carbon::now()); } - /** - * Get the components relation. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function components() - { - return $this->hasMany(ScheduleComponent::class); - } - /** * Get the presenter class. * diff --git a/app/Models/Subscriber.php b/app/Models/Subscriber.php index de3e3838c..964a73eba 100644 --- a/app/Models/Subscriber.php +++ b/app/Models/Subscriber.php @@ -90,6 +90,16 @@ class Subscriber extends Model implements HasPresenter }); } + /** + * Get all of the meta relation. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function meta() + { + return $this->morphMany(Meta::class, 'meta'); + } + /** * Get the subscriptions relation. *