PHP code example of laravel-enso / upgrade

1. Go to this page and download the library: Download laravel-enso/upgrade 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/ */

    

laravel-enso / upgrade example snippets


return [
    'folders' => ['.'],
    'vendors' => ['laravel-enso'],
];

use Illuminate\Support\Facades\Schema;
use LaravelEnso\Upgrade\Contracts\MigratesTable;

class AddStatusColumn implements MigratesTable
{
    public function isMigrated(): bool
    {
        return Schema::hasColumn('orders', 'status');
    }

    public function migrateTable(): void
    {
        Schema::table('orders', function ($table) {
            $table->string('status')->nullable();
        });
    }
}

use LaravelEnso\Upgrade\Contracts\MigratesStructure;
use LaravelEnso\Upgrade\Traits\StructureMigration;

class OrdersStructureUpgrade implements MigratesStructure
{
    use StructureMigration;

    protected array $permissions = [
        ['name' => 'orders.index', 'description' => 'List orders', 'is_default' => true],
    ];

    protected array $roles = ['admin'];
}
bash
php artisan vendor:publish --tag=upgrade-config
bash
php artisan enso:upgrade
bash
php artisan enso:upgrade --manual
bash
php artisan enso:upgrade --before-migration
bash
php artisan enso:upgrade:status