<commit_before><?php

namespace Fish\Cascade;

trait Cascade {

 public static function boot()
 {
  static::deleting(function ($model) {
    if (property_exists($model, 'cascade') && is_array($model->cascade)) {
      foreach ($model->cascade as $relation) {
        if (method_exists($model, $relation)) {
          foreach ($model->{$relation}()->get() as $related)
            $related->delete();
        }
      }
    }
  });
}

}<commit_msg>wrap cascade array with a method<commit_after><?php

namespace Fish\Cascade;

trait Cascade {

 public static function boot()
 {

  parent::boot();

  static::deleting(function ($model) {
    if (property_exists($model, 'cascade') && is_array($model->cascade)) {
      foreach ($model->getCascade() as $relation) {
        if (method_exists($model, $relation)) {
          foreach ($model->{$relation}()->get() as $related)
            $related->delete();
        }
      }
    }
  });
}

protected function getCascade() {
  return $this->cascade;
}

}
{'fraction_non_alphanumeric': 0.1713426853707415, 'fraction_numerical': 0.0, 'mean_word_length': 3.028225806451613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5259266', 'n_tokens_mistral': 311, 'n_tokens_neox': 308, 'n_words': 65}