Skip to main content

Cascade Soft Deletes: Soft-Delete Children Automatically

Premium
1:59

The Full Lesson is Only for Premium Members

Want to access all of our courses? (39 h 29 min)

You also get:

66 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Richard A. Hoyle avatar

Grate course trying to work with the dyrynda Laravel cascade soft deletes 4.3 however when I tune the phpUnit test I get the following Error:

 
FAIL Tests\Feature\ProfileTest
✓ profile page is displayed 0.04s
✓ profile information can be updated 0.03s
✓ email verification status is unchanged when the email address is unchanged 0.03s
⨯ user can delete their account 0.35s
✓ correct password must be provided to delete account 0.08s
──────────────────────────────────────────────────────────────────────────────────────────────────────────
FAILED Tests\Feature\ProfileTest > user can delete their account
Expected response status code [201, 301, 302, 303, 307, 308] but received 500.
Failed asserting that false is true.
 
The following exception occurred during the last request:
 
Dyrynda\Database\Support\CascadeSoftDeleteException: Relationship [companies] must exist and return an object
of type Illuminate\Database\Eloquent\Relations\Relation in C:\xampp\htdocs\imr\ironmanrecycling\vendor\dyrynda
\laravel-cascade-soft-deletes\src\CascadeSoftDeleteException.php:18
 
 
 
Relationship [companies] must exist and return an object of type Illuminate\Database\Eloquent\Relations\Relati
on
 
at tests\Feature\ProfileTest.php:76
72▕ ]);
73▕
74▕ $response
75▕ ->assertSessionHasNoErrors()
➜ 76▕ ->assertRedirect('/');
77▕
78▕ $this->assertGuest();
79▕ $this->assertSoftDeleted($user->fresh());
80▕ }
 
 
Tests: 1 failed, 25 passed (55 assertions)
Duration: 3.35s

Any suggestions? Ps The soft delete did work befor I changed to this CascadeSoftDeletes.

Richard A. Hoyle avatar

removed the CascadeSoftDeletes and it passes.