Skip to content

Add annotation for relationships for model generation #203

@DenTray

Description

@DenTray

Description


What needs to be done?


When generating a model, if relationships are specified, add an annotation property for each relationship. Each annotation must include a name of the generated relationship and specify the appropriate data type for the property.

For hasOne relationships, use the datatype as the optional model name used in the relation.
For hasMany relationships, use the datatype collection .
And etc.
Include similar handling for other relationship types as necessary.

Expected Outcome


What is the expected result?


The generated model should contain annotated properties for each relationship. Each annotation clearly describes the relationship and correctly reflects the data type. This improves code clarity.

Verification Scenarios


How can this be tested?


1. Generate a model with relationships. Verify that the annotation property correctly uses the datatype and includes a relationship description.
2. Test with models that have multiple different relationship types to confirm correct annotation is applied to all.
3. Confirm no errors occur during model generation.
4. Ensure annotations are in a consistent, readable format.
5. Validate that consuming services or tools recognize and utilize the annotated properties correctly.

Resources


Materials (Screenshots, Figma Links, References)


Description of the relationship: https://laravel.com/docs/12.x/eloquent-relationships#has-one-of-many

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions