Make Soft Deleted Relationships Nullable (#1749)

This commit is contained in:
Evan Burrell
2026-01-11 14:34:18 +01:00
committed by GitHub
parent 2ac73f2953
commit b0dcd7c62f
9 changed files with 381 additions and 0 deletions
+22
View File
@@ -911,9 +911,31 @@ class ModelsCommand extends Command
}
}
if ($this->relatedModelUsesSoftDeletes($relationObj)) {
return true;
}
return false;
}
/**
* Check if the related model uses the SoftDeletes trait
*
* @param Relation $relationObj
*
* @return bool
*/
protected function relatedModelUsesSoftDeletes(Relation $relationObj): bool
{
if (!$this->laravel['config']->get('ide-helper.soft_deletes_force_nullable', true)) {
return false;
}
$relatedModel = $relationObj->getRelated();
return in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', class_uses_recursive($relatedModel));
}
/**
* Check if the morphTo relation is nullable
*