Delete related points when deleting metrics

This commit is contained in:
James Brooks 2016-12-15 20:09:59 +00:00
parent cb5aac9637
commit 027b2e13e9

View File

@ -141,6 +141,21 @@ class Metric extends Model implements HasPresenter
'visible',
];
/**
* Overrides the models boot method.
*
* @return void
*/
public static function boot()
{
parent::boot();
// When deleting a metric, delete the points too.
self::deleting(function ($model) {
$model->points()->delete();
});
}
/**
* Get the points relation.
*