io-digital / truncate-tables
A Laravel package to easily truncate database tables when running seeder files
1.0.1
2021-05-02 02:22 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^5.0|^6.0|^7.0|^8.0
- illuminate/database: ^5.0|^6.0|^7.0|^8.0
- illuminate/support: ^5.0|^6.0|^7.0|^8.0
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- brianium/paratest: ^6.2
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2024-12-06 21:03:59 UTC
README
Installation
You can install the package via composer:
composer require io-digital/truncate-tables
Usage
In database/seeders/DatabaseSeeder.php
:
<?php namespace Database\Seeders; use Illuminate\Database\Seeder; use IoDigital\TruncateTable\TruncateTable; class DatabaseSeeder extends Seeder { /** * Seed the application's database. * * @return void */ public function run() { TruncateTable::fromArrays([ 'users', 'posts' ])->clean(); // Or like the following TruncateTable::fromArrays([ 'users', 'posts' ], [ UserTableSeeder::class, PostTableSeeder::class, ])->cleanAndSeed(); } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.