Skip to content

Commit

Permalink
Restore previous tests order (#159)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Towers <[email protected]>
  • Loading branch information
mjauvin and LukeTowers authored Oct 19, 2023
1 parent d1b95f7 commit 2941ef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,6 @@ protected function performDeleteOnRelations()
* Hard 'delete' definition
*/
foreach ($relations as $name => $options) {
if (!$relation = $this->{$name}) {
continue;
}

if (in_array($type, ['belongsToMany', 'morphToMany', 'morphedByMany'])) {
// we want to remove the pivot record, not the actual relation record
if (Arr::get($options, 'detach', true)) {
Expand All @@ -1025,6 +1021,11 @@ protected function performDeleteOnRelations()
continue;
}

// Attempt to load the related record(s)
if (!$relation = $this->{$name}) {
continue;
}

if ($relation instanceof EloquentModel) {
$relation->forceDelete();
} elseif ($relation instanceof CollectionBase) {
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Traits/SoftDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ protected function performSoftDeleteOnRelations()
$definitions = $this->getRelationDefinitions();
foreach ($definitions as $type => $relations) {
foreach ($relations as $name => $options) {
if (!$relation = $this->{$name}) {
if (!array_get($options, 'softDelete', false)) {
continue;
}
if (!array_get($options, 'softDelete', false)) {
// Attempt to load the related record(s)
if (!$relation = $this->{$name}) {
continue;
}
if (in_array($type, ['belongsToMany', 'morphToMany', 'morphedByMany'])) {
Expand Down

0 comments on commit 2941ef4

Please sign in to comment.