feyyazcankose/laravel-dynamic-migrate 问题修复 & 功能扩展

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

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

feyyazcankose/laravel-dynamic-migrate

最新稳定版本:1.0.3

Composer 安装命令:

composer require feyyazcankose/laravel-dynamic-migrate

包简介

README 文档

README

The Laravel Dynamic Migrate package allows you to dynamically create or update database tables based on your Eloquent models. This can save you time and effort, as you no longer have to manually create or update your database tables every time you make changes to your models.

Installation

You can install the Laravel Dynamic Migrate package via Composer:

composer require feyyazcankose/laravel-dynamic-migrate

Once the package is installed, you can run the following command to generate the necessary migration files:

php artisan dynamic:migrate

Usage

To use the Laravel Dynamic Migrate package, you need to add the setColumns() method to your Eloquent models. This method should define the columns for your database table, using the Blueprint class from the Illuminate\Database\Schema namespace. Here's an example:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Feyyazcankose\LaravelDynamicMigrate\DynamicMigration;

class MyModel extends Model
{
    protected $table = 'my_model';

    public function setColumns(Blueprint $table)
    {
        $table->increments('id');
        $table->string('name');
        $table->text('description')->nullable();
        $table->timestamps();
    }

    // Optional: You can also define an `updateColumns()` method to update your table columns
    // public function updateColumns(Blueprint $table)
    // {
    //     DynamicMigration::renameColumn('old_column_name', 'new_column_name',$this->table, $table);
    //     DynamicMigration::dropColumn('column_to_delete',$this->table, $table);
    //     DynamicMigration::addColumn('new_column_name',$this->table, function(Blueprint $table) {
    //         $table->string('new_column_name')->nullable();
    //     });
    //     DynamicMigration::changeColumn('column_to_change',$this->table, function(Blueprint $table) {
    //         $table->string('column_to_change')->nullable();
    //     });
    // }
}

Once you have defined the setColumns() method for your models, you can run the dynamic:migrate command to generate or update your database tables:

php artisan dynamic:migrate

Contributing If you find any issues with the Laravel Dynamic Migrate package, or if you have any suggestions for new features or improvements, feel free to open an issue or submit a pull request on GitHub.

License The Laravel Dynamic Migrate package is open-source software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固