Delete related points when deleting metrics
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user