developerawam/generate-migration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

developerawam/generate-migration

最新稳定版本:v2.0.5

Composer 安装命令:

composer require developerawam/generate-migration

包简介

This package automatically generates migration files for your Laravel application. With this feature, you can quickly create database structures without writing SQL code manually. Simply specify the model you want to create, and this package will handle the rest, streamlining development and minimiz

README 文档

README

Latest Version on Packagist Total Downloads

This package automatically create and generate migration files for your Laravel application. With this feature, you can quickly create database structures without writing SQL code manually. Simply specify the model you want to create, and this package will handle the rest, streamlining development and minimizing human errors.

Requirements

  • Laravel 11
  • PHP ^8.0
  • TailwindCSS ^3.4

Installation

You can install the package via composer:

composer require developerawam/generate-migration

Publish the Assets

Run the following Artisan command to publish the assets to your Laravel application's public directory:

php artisan vendor:publish --tag=assets

Usage

After installation, you can access the user interface to auto create generate models, migrations, and tables by visiting the following URL in your browser:

/generate-migration/generate-ui

This screenshot showcases the user interface provided by the package. The interface allows users to easily generate models, migrations, and database tables in a Laravel project through a simple and intuitive UI.

UI Screenshot

Use the GenerateMigration class to create a migration with the desired table name and columns. The example code below demonstrates how to create a migration for a post table with columns:

    use Developerawam\GenerateMigration\GenerateMigration;

    // table name example
    $table_name = "post";

    // table column example
    $table_colom = [
        [
            "name"      => "name",
            "type"      => "string",
            "default"   => null
        ],
        [
            "name"      => "description",
            "type"      => "text",
            "default"   => null
        ],
        [
            "name"      => "age",
            "type"      => "integer",
            "default"   => 20
        ],
        [
            "name"      => "views",
            "type"      => "bigInteger",
            "default"   => 0
        ],
        [
            "name"      => "price",
            "type"      => "decimal",
            "precision" => 8,
            "scale"     => 2,
            "default"   => 0.00
        ],
        [
            "name"      => "rating",
            "type"      => "float",
            "precision" => 8,
            "scale"     => 2,
            "default"   => 0.00
        ],
        [
            "name"      => "birthdate",
            "type"      => "date",
            "default"   => "2000-01-01"
        ],
        [
            "name"      => "appointment_time",
            "type"      => "time",
            "default"   => "12:00:00"
        ],
        [
            "name"      => "created_at",
            "type"      => "timestamp",
            "default"   => "CURRENT_TIMESTAMP"
        ],
        [
            "name"      => "is_active",
            "type"      => "boolean",
            "default"   => true
        ],
        [
            "name"      => "status",
            "type"      => "enum",
            "values"    => ["pending", "approved", "rejected"],
            "default"   => "pending"
        ],
        [
            "name"      => "settings",
            "type"      => "json",
            "default"   => "{\"theme\": \"dark\", \"notifications\": true}"
        ]
    ];

    // table_name must be string
    // table_column must be array object
    GenerateMigration::create($table_name, $table_colom);

Code Explanation

  • $table_name: The name of the table you want to create, in this case, post.
  • $table_columns: An array of columns to be created in the table. Each column is an array containing the column name (name) and data type (type).
  • GenerateMigration::create($table_name, $table_columns): Calls the create method from the GenerateMigration class to create a migration based on the specified table name and columns.

Testing

composer test

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Support the Project

If you find this project useful and would like to support its development, you can make a donation:

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固