Laravel Module Generator

v 1.3.*

Migration Guide

Migration from old YAML format

If you're upgrading from an older version of this package, here's how the YAML format has changed:

Old format (deprecated):

Product:
  generate:
    model: true
    migration: true
    controller: true
    service: true
    request: true
    resource: true
    collection: true
    seeder: false
  fields:
    name: string:unique
  relations:
    creator:
      type: belongsTo
      model: User
    variants:
      type: hasMany
      model: ProductVariant
      makeRequest: true

New format (current):

Product:
  generate_except: seeder  # Much simpler!
  fields:
    name: string:unique
  relations:
    belongsTo: User:creator
    hasMany: ProductVariant:variants
  nested_requests: variants

Key differences:

  1. Generation control: Use generate_only or generate_except instead of individual boolean flags
  2. Compact relations: Use relationType: Model:functionName format instead of nested arrays
  3. Nested requests: Use nested_requests at model level instead of makeRequest per relation
  4. Cleaner syntax: Less YAML nesting, easier to read and maintain

The package still supports the old format for backward compatibility, but we recommend migrating to the new format for better maintainability.

Conventions and output locations

  • Models: app/Models/{Model}.php
  • Migrations: database/migrations/*_create_{table}_table.php
  • Controllers: app/Http/Controllers/{Model}Controller.php
  • Services: app/Services/{Model}Service.php
  • Requests: app/Http/Requests/{Model}Request.php
  • Resources: app/Http/Resources/{Model}Resource.php
  • Collections: app/Http/Resources/{Model}Collection.php
  • Seeders: database/seeders/{Model}Seeder.php
  • Routes: Appended to routes/api.php or your configured route file
  • Postman: module/postman_collection.json
  • DBML: module/dbdiagram.dbml
  • Backups: module/backups/{timestamp}/

If you need additional generator behaviors (custom templates, naming conventions), consider extending the package or contributing a PR.