PHP code example of maheralyamany / laravel-advanced-migration
1. Go to this page and download the library: Download maheralyamany/laravel-advanced-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/ */
maheralyamany / laravel-advanced-migration example snippets
$app->register(\AdvancedMigration\MigrationGeneratorProvider::class);
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username', 128)->nullable()->index();
$table->string('email', 255)->index();
$table->string('password', 255);
$table->string('first_name', 45)->nullable()->index();
$table->string('last_name', 45)->index();
$table->string('timezone', 45)->default('America/New_York');
$table->unsignedInteger('location_id');
$table->softDeletes();
$table->string('remember_token', 255)->nullable();
$table->timestamps();
$table->foreign('location_id', 'users_location_id_foreign')->references('id')->on('locations')->onUpdate('cascade')->onDelete('cascade');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
bash
php artisan vendor:publish --provider="AdvancedMigration\MigrationGeneratorProvider"
bash
php artisan generate:advanced-migrations
bash
php artisan generate:advanced-migrations --path=database/migrations
bash
php artisan generate:advanced-migrations --connection=mysql2
bash
php artisan generate:advanced-migrations --empty-path