PHP code example of iyogesharma / multi-db

1. Go to this page and download the library: Download iyogesharma/multi-db library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iyogesharma / multi-db example snippets



    composer san vendor:publish --tag=multidb:migrations

    php artisan vendor:publish --tag=multidb:models

    //optional
    
    php artisan vendor:publish --tag=multidb:config

 

            

        use Illuminate\Database\Schema\Blueprint;
        use Illuminate\Support\Facades\Schema;
        use YS\MultiDB\Migration;

        return new class extends Migration
        {
            /**
             * Run the migrations.
             */
            public function up(): void
            {
                Schema::create(static::$schema.'.clients', function (Blueprint $table) {
                    $table->id();
                    $table->string('code');
                    $table->string('name');
                    $table->string('created_by');
                    $table->string('modified_by')->nullable();
                    $table->boolean('active')->default(1);
                    $table->timestamps();
                });
            }

            /**
             * Reverse the migrations.
             */
            public function down(): void
            {
                Schema::dropIfExists('clients');
            }
        };

    

  protected static $inMainDb = false;
 artisan new:seed 
 php artisan new:migrations 
 php artisan new:migrations_rollback 
 php artisan new:seed --path=App\\Newdatabase\\Seeders\\TESTSeeder