PHP code example of plank / laravel-schema-events

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

    

plank / laravel-schema-events example snippets




namespace App\Listeners;

use Plank\LaravelSchemaEvents\Events\TableCreated;

class LogTableCreation
{
    public function handle(TableCreated $event)
    {
        \Log::info("Table {$event->table} was created with columns: " . implode(', ', $event->columns->toArray()));
    }
}

protected $listen = [
    TableCreated::class => [
        LogTableCreation::class,
    ],
];

return [
    'listeners' => [
        'ran' => MigrationRan::class,
        'finished' => MigrationsFinished::class,
    ],
    
    'commands' => [
        'renamed_columns' => ['renameColumn'],
        'dropped_columns' => ['dropColumn'],
        'added_indexes' => [
            'primary',
            'unique',
            'index',
            'fulltext',
            'spatialIndex',
        ],
        // ... additional commands
    ],
];

public readonly string $table;
public readonly Collection $columns;      // Added columns
public readonly Collection $indexes;      // Added indexes
public readonly Collection $foreignKeys;  // Added foreign keys

public readonly string $table;
public readonly Collection $addedColumns;
public readonly Collection $droppedColumns;
public readonly Collection $renamedColumns;     // Contains [from => x, to => y]
public readonly Collection $modifiedColumns;
public readonly Collection $addedIndexes;
public readonly Collection $droppedIndexes;
public readonly Collection $renamedIndexes;     // Contains [from => x, to => y]
public readonly Collection $addedForeignKeys;
public readonly Collection $droppedForeignKeys;

public readonly string $table;

public readonly string $from;
public readonly string $to;
bash
php artisan vendor:publish --tag="schema-events-config"