DevTools: Model
DevTools includes a fully featured Model Creation Routine which we will detail here
Starting off
To start, simply run econsor:dev:addmodel.
It will ask you for the following Infos:
Plugin- Select the Plugin you want to add the CMS to (type in the corresponding number)Model Name- This is the Name used in Filenames and Namespaces, so for example type MyModelTable Name- This is used as the SQL table name, so for example type ec_my_modelTranslated?- This will make your model a translated model and also generate a corresponding translation Model
Adding Fields
You're now being asked if you want to add fields. If you choose y, you have the following options:
Regular Fields
If you pick any of these you will be asked for the Field Name - The Field name in camelCase - For example myBoolField
You have the choice between these data types - They should be self-explanatory:
boolintfloatstringlongtextarray(/JSON Field)id(necessary for associations and references)date
Associations
You can create Associations to other Entities by choosing one of these options:
association - one to oneassociation - one to manyassociation - many to oneassociation - many to many
Translated Field
You need to have Translated? selected in the model creation in the previous step for this to be pickable.
If you pick this, you will then be asked what type the field should be. From there on it's like it's a normal field. (See above/below)
Translated Field
Other
exit- Quit Routine
Associations
If you have chosen an Association Field it will ask you for these infos (in our example we want to link a field in our entity called image to the id Field in the Media Entity):
Target Entity Name: The Entity the Association points to - In our example this is MediaEntityField Name: The name of the Field we're creating in OUR Entity - In our example this is image. Please note: The corresponding field for the 'id' will be created automatically.Target Table Name: The SQL name of our target table - In our example this is mediaTarget Field Name: The SQL name of our target field - In our example this is idTarget Definition Name: The name of our Target Entity Definition - In our example this is MediaDefinitionTarget Entity Field Name: The name of the target field in the Definition - In our example this is also id but be aware other field names will be in camelCase instead of snake_case.