承接 theupriser/laravel-migration-extensions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

theupriser/laravel-migration-extensions

最新稳定版本:v1.2.0

Composer 安装命令:

composer require theupriser/laravel-migration-extensions

包简介

Laravel migration extensions

README 文档

README

This package contains a couple of extensions for the laravel migrator.

Installation

You can install the package via composer with the following steps:

Install the theupriser/laravel-migration-extensions package.

composer require theupriser/laravel-migration-extensions

Usage

Conditional

The Conditional Interface makes it possible to run migrations based on conditions in your application. Sometimes you don't need tables or columns if your application doesn't need them.

How to

  1. Implement Conditional interface in your Seeder class.
    return new class extends Migration implements Conditional 
    
  2. Add seeders from method stub, add seeders you want to run to the array
    public function condition(): bool
    {
     return true; // or return false if you don't want it to run.
    }
    
  3. Run php artisan migrate

Seedable

The Seedable Interface makes it possible to run seeders after the migration runs. Every unique seed added will be executed once after the migrations have run. This function exists because Tables can change and so do the columns in your tables. If seeders are added to an earlier migration they break and have to be deleted from the migrations to be runnable again. You constantly have to keep track.

This changes that! you add the seeders to the seeders method in the Seedable class and the migrator will keep track for you. It even checks if the Seeder still exists in your project.

How to

  1. Implement Seedable interface in your Seeder class.
    return new class extends Migration implements Seedable 
    
  2. Add seeders from method stub, add seeders you want to run to the array
    public function seeders(): array
    {
     return [
         \Database\Seeders\DatabaseSeeder::class,
     ];
    }
    
  3. Run php artisan migrate

Credits

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

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