Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships that soft-delete should have nullable property type-hints #290

Open
finiteinfinity opened this issue Jul 2, 2024 · 0 comments

Comments

@finiteinfinity
Copy link
Contributor

Given these tables

CREATE TABLE users
(
    id        BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    managerId BIGINT UNSIGNED NOT NULL,
    deletedAt DATETIME(6)     NULL,
    CONSTRAINT users_managerId_foreign
        FOREIGN KEY (managerId) REFERENCES users (id)
)

we get the following type-hints for the User model:

@property User $manager

however, when the related user record is (soft) deleted, we no longer get access to the data through the property thanks to the SoftDeleting scope Laravel provides.

The suggestion here is to add a new config value (to preserve BC) which generated these properties as nullable to reflect the fact that they may actually contain a null value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant