-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Need to extend model generation logic by generating @property annotations for each model's field
Description
What needs to be done?
Enhance the existing model generation script to automatically create @property annotations for each field of the model. For each field declared in the generation command, the script should determine the corresponding PHP type and generate a @property annotation indicating the type and field name in the model's PHPDoc block. The annotations should be added to the top of the generated model file. For example, fields like -e User should generate @property int user_id, and timestamps like -t first_booked_at should generate @property Carbon first_booked_at.
Expected Outcome
What is the expected result?
The generated model file will contain accurate @property annotations reflecting each field’s type and name. For the example command:
php artisan make:entity Property -S name -e User -F price -b is_free -t first_booked_at -j meta
The model will include the following PHPDoc annotations:
/**
* @property int user_id
* @property float price
* @property string name
* @property bool is_free
* @property Carbon first_booked_at
* @property array meta
*/
Verification Scenarios
How can this be tested?
- Run the model generation command with various combinations of fields and flags (like
-e,-F,-S, etc.). - Check that the generated model file contains
@propertyannotations correctly mapping field names to their expected types and names (including type hints likeint,float,string,bool,Carbon,array). - Verify that all fields passed in the command are included as annotations in the model PHPDoc block without duplicates or typos.
- Confirm the annotations are syntactically correct and do not cause PHPDoc or IDE parsing errors.
- Ensure no debug information or errors occur during generation.