PHP code example of developerawam / generate-migration

1. Go to this page and download the library: Download developerawam/generate-migration 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/ */

    

developerawam / generate-migration example snippets



    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);

bash
php artisan vendor:publish --tag=assets