Courses

Eloquent: The Expert Level (Laravel 9)

Cascade Soft Deletes: Soft-Delete Children Automatically

Previous: Parental by Tighten: Relationship to Self
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.

avatar

removed the CascadeSoftDeletes and it passes.

avatar
You can use Markdown
avatar
You can use Markdown