programic/laravel-triggers

Add mysql triggers to migration files

v2.0.0 2023-04-12 14:26 UTC

This package is auto-updated.

Last update: 2024-11-17 10:48:26 UTC


README

Latest Version on Packagist Total Downloads

This package allows you to add MySql triggers simplified in migration files.

Installation

This package requires PHP 8.1 (or higher) and Laravel 10.

composer require programic/laravel-triggers

Replace alias Schema Facade with our Facade in config/app.php

'Schema' => Programic\Triggers\Facades\Schema::class,

Add directory to composer autoloader: "Database\\Seeders\\": "database/seeders/"

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    }
},

Basic Usage

# Create Trigger
php artisan make:triggers UpdateColumnWhenRowDeletedTrigger

Use trigger in migration file

Schema::createTrigger(UpdateColumnWhenRowDeletedTrigger::class);
Schema::createTriggerWhenNotExists(UpdateColumnWhenRowDeletedTrigger::class);

Schema::trigger(function (Trigger $trigger) {
    
});

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email info@programic.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.