PHP code example of garanaw / seedable-migrations

1. Go to this page and download the library: Download garanaw/seedable-migrations 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/ */

    

garanaw / seedable-migrations example snippets




declare(strict_types=1);

use Garanaw\SeedableMigrations\Blueprint;
use Garanaw\SeedableMigrations\Enum\SeedAt;
use Garanaw\SeedableMigrations\Migration;

return new class extends Migration
{
    public function up(): void
    {
        $this->schema->create(table: $this->getTable(), callback: static function (Blueprint $table) {
            $table->id();
            $table->timestamps();
        });
    }

    public function getTable(): string
    {
        return $this->table;
    }

    public function seedAt(): SeedAt
    {
        return SeedAt::EACH;
    }

    public function down(): void
    {
        $this->schema->dropIfExists($this->getTable());
    }
}



declare(strict_types=1);

use Garanaw\SeedableMigrations\Seeder;

return MySeeder extends Seeder
{
    public function run(): bool
    {
        // Your seeder code here
    }

    public function getData(): array
    {
        return [];
    }
}

    public function seedersUp(): \Illuminate\Support\Collection
    {
        return collect([
            MySeeder::class,
        ]);
    }

    public function seedersDown(): \Illuminate\Support\Collection
    {
        return collect([
            MySeeder::class,
        ]);
    }

    public function shouldSeed(): bool
    {
        return true;
    }

    public function configure(
        \Illuminate\Config\Repository $config,
        \Illuminate\Foundation\Application $app,
        \Illuminate\Contracts\Console\Kernel $artisan,
        \Illuminate\Contracts\Debug\ExceptionHandler $exceptionHandler,
        App\Providers\RouteServiceProvider $routeServiceProvider,
        \Psr\Log\LoggerInterface $logger,
    ): void {
        // Your configuration code here. You can inject anything that is configured in your container
    }
bash
php artisan vendor:publish --provider="Garanaw\SeedableMigrations\SeedableMigrationsServiceProvider"