# Example configuration for a model with polymorphic relationships
# This demonstrates a Comment model that can belong to either a Post or a Video

model:
  name: Comment
  tableName: comments
  displayName: Comment
  description: User comments that can belong to different content types
  
  # Fields definition
  fields:
    - name: id
      type: integer
      label: ID
      nullable: false
    
    - name: body
      type: text
      label: Comment
      nullable: false
      validations:
        - required
        - min: 3
        - max: 1000
    
    - name: rating
      type: integer
      label: Rating
      nullable: true
      validations:
        - min: 1
        - max: 5
    
    - name: is_approved
      type: boolean
      label: Approved
      nullable: false
      default: false
  
  # Polymorphic relationship definition
  relationships:
    - name: commentable  # This is the polymorphic relationship
      type: morphTo
      polymorphicTypes:
        - model: Post
          displayField: title
        - model: Video
          displayField: name
      required: true
      ui:
        label: Related Content
        showInTable: true
        showInForm: true
    
    - name: user
      type: belongsTo
      model: User
      displayField: name
      required: true
      ui:
        label: Author
        showInTable: true
        showInForm: true

# UI configuration
ui:
  tableFields:
    - id
    - body
    - user
    - commentable
    - is_approved
  itemsPerPage: 15
  enableSearch: true
  enableFilters: true
  defaultSort:
    field: id
    direction: desc

# Routing configuration
routes:
  apiPrefix: api/comments
  frontendPath: comments
  menuTitle: Comments
  menuIcon: fa-comments

# Inverse side configurations for the polymorphic relationship
# These would be in the Post and Video model configurations

# Post model relationship section example:
# relationships:
#   - name: comments
#     type: morphMany
#     model: Comment
#     morphName: commentable
#     ui:
#       label: Comments
#       showInTable: false
#       showInForm: true

# Video model relationship section example:
# relationships:
#   - name: comments
#     type: morphMany
#     model: Comment
#     morphName: commentable
#     ui:
#       label: Comments
#       showInTable: false
#       showInForm: true