Skip to content

Allow one to one _exists properties to be generated #1741

@billypoke

Description

@billypoke

Currently, the write_model_relation_exists_properties config option only writes these properties if the relation is a many return type https://github.com/barryvdh/laravel-ide-helper/blob/master/src/Console/ModelsCommand.php#L826

Our use case is as follows:
We have a User model, and several different types of users with various properties that may be linked to the User via user_id/a HasOne relationship. When sending data to the frontend, we include the various _exists fields to be used as flags for the frontend to control which portions of the ui are shown and/or enabled. We don't always need the actual contents of the related models, so a true/false for the existence works for us. It would be great if the _exists properties could be added for these types of relationships.

Querying for existence/absence is not dependent on the relationship being a many-X https://laravel.com/docs/12.x/eloquent-relationships#querying-relationship-existence

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions