<commit_before># Laravel 5 Soft Cascade
Cascade delete and restore when using the Laravel SoftDeletes feature.

# Why do I need it?
### To make it easy to soft delete and restore relations.
If you enjoy features like MySQL cascade deleting but want to use Laravels SoftDeletes feature you'll need to do some extra steps to ensure your relations are properly deleted or restored.

This package is intended to replace those steps with a simple array that defines the relations you want to cascade.

# Installation
Install with composer
~~~
  composer require askedio/laravel5-soft-cascade
~~~

Register the service provider in your config/app.php
~~~
Askedio\SoftCascade\Providers\GenericServiceProvider::class,
~~~

Enable the trait and define what to cascade in $softcascade in your Models, [example](https://github.com/Askedio/laravel5-soft-cascade/blob/master/tests/app/User.php).
~~~
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;

protected $softcascade = ['profiles'];
~~~


# Supported Databases
* MySQL
* SQLite

# Testing
I have written some very basic tests, certainly more needs to be done here. If you find this useful please help by testing other databases or writing better unit tests because I must move on.
<commit_msg>Updated read<commit_after># Laravel 5 Soft Cascade
Cascade delete and restore when using the Laravel SoftDeletes feature.

# Why do I need it?
### To make it easy to soft delete and restore relations.
If you enjoy features like MySQL cascade deleting but want to use Laravels SoftDeletes feature you'll need to do some extra steps to ensure your relations are properly deleted or restored.

This package is intended to replace those steps with a simple array that defines the relations you want to cascade.

# Installation
Install with composer
~~~
  composer require askedio/laravel5-soft-cascade
~~~

Register the service provider in your config/app.php
~~~
Askedio\SoftCascade\Providers\GenericServiceProvider::class,
~~~

In your Model(s), enable the trait and define $softcascade. [Example](https://github.com/Askedio/laravel5-soft-cascade/blob/master/tests/app/User.php).
~~~
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;

protected $softcascade = ['profiles'];
~~~
`$softcascade` is an array of your relation names, in the [example](https://github.com/Askedio/laravel5-soft-cascade/blob/master/tests/app/User.php) you'll see we've defined `function profiles()` for the relation.

Nested relations work by defining `$softcascade` in the related Model as you can see [here](https://github.com/Askedio/laravel5-soft-cascade/blob/master/tests/app/Profiles.php).



# Supported Databases
* MySQL
* SQLite

# Testing
I have written some very basic tests, certainly more needs to be done here. If you find this useful please help by testing other databases or writing better unit tests because I must move on.

{'fraction_non_alphanumeric': 0.07786741494212557, 'fraction_numerical': 0.0028060329708874078, 'mean_word_length': 4.844262295081967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1100991', 'n_tokens_mistral': 826, 'n_tokens_neox': 764, 'n_words': 342}