Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

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? (29 h 14 min)

You also get:

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

Already a member? Login here

Comments & Discussion

RA
Richard A. Hoyle ✓ Link copied!

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.

RA
Richard A. Hoyle ✓ Link copied!

removed the CascadeSoftDeletes and it passes.