roger-russel/schemaum

Laravel的辅助工具,用于处理预索引的数据库和表

v1.2.0 2018-10-08 20:16 UTC

This package is auto-updated.

Last update: 2024-09-09 13:53:30 UTC


README

安装

composer require roger-russel/schemaum

API

/**
 * @param string $databaseLike [ like string on database ]
 * @param string $userLik [ like string on database ]
 * @param function [This function is the very same which is required on Laravel]
 */
Schemas::table($databaseLike, $userLik, function(Blueprint $table){});

用法

use Schemaum\Schemas;
Schemas::table('database_%','users_%', function(Blueprint $table){
    $table->string('phone');
});

使用示例

<?php

use Schemaum\Schemas; // use Schemas instead of Laravel Schema
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterSomeTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //Firts parameter is database like, and the second one is table like
        Schemas::table('database_%','users_%', function(Blueprint $table){
            $table->string('phone');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //Firts parameter is database like, and the second one is table like
        Schemas::table('database_%','users_%',function(Blueprint $table){
            $table->dropColumn('phone');
        });
    }
}