simianbv/generators

生成器

安装数: 2,474

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:项目

v1.0.12 2021-06-11 14:03 UTC

This package is auto-updated.

Last update: 2024-09-11 21:08:56 UTC


README

为Laravel生成控制器、模型、视图和迁移的生成器

安装

要安装,请使用

composer require simianbv/generators

下一步;

artisan vendor:publish --provider="Simianbv\Generators\GeneratorServiceProvider" --tag=generator-stubs artisan vendor:publish --provider="Simianbv\Generators\GeneratorServiceProvider" --tag=generator-config

以获取占位符,下一步;

定义你的 YAML

YAML 定义已经准备好供您使用,并可用于创建模型、控制器、资源,以及未来将创建的过滤器。

Role:                       # the name of the model
  namespace: Acl            # Define the relative namespace
  timestamps: true          # Allow timestamps for the model
  softDelete: true          # Allow softdeletes
  columns:                  # Define your columns
    id:                     # The name of the column
      type: bigInteger      # The column type
      primary: true         # Whether it's primary
      unsigned: true        # Should be unsigned
    name:                   # The name of the column
      type: string          # The column type
      nullable: false       # Nullable or not
      length: 50            # The length of the column
      unique: true          # Whether it should be unique
  relations:                # Define the relations
    Group:                  # The name of the related Model
      namespace: Acl        # Define the related Model's namespace
      type: belongsToMany   # Define the type of relation
      local: id             # Define the primary key in the related model
      foreign: id           # Define what the foreign key should be 
      

另一个示例

RoleUser:                   # The name of the pivot table
  namespace: Acl            # The relative namespace
  pivot_only: true          # Set to true if this is only a pivt table
  timestamps: true          # Whether you want timestamps
  columns:                  # Define your columns
    id:                     # The name of the column
      type: bigInteger      # The type
      primary: true         # Primary yes or no
      unsigned: true        # Whether is should be unsigned or not
    role_id:                # The name of the column ( note the _id )
      type: bigInteger      # The column type
      nullable: false       # Nullable yes or no
    user_id:                # The name of the column ( note the _id )
      type: bigInteger      # The column type
      nullable: false       # Nullable yes or no
  relations:                # The relations
    Role:                   # The name of the related Model
      namespace: Acl        # The relative namespace this model resides in
      type: hasOne          # The relation type
      local: role_id        # The local key ( note the _id )
      foreign: id           # The foreign table's primary key
    User:                   # The name of the related Model
      namespace:            # The namespace can be left blank
      type: hasOne          # The Relation type
      local: user_id        # The local column
      foreign: id           # The foreign model's column

要定义 JSON 模式,将在 /app/Resources/Json/ 目录中生成一个 Resource 类,您可以在其中进一步定义模式。您可以为它们添加布局元素,将它们包裹在内部或水平或垂直对齐。