I'm creating a package and want to have db seeds in it. All those seeds will do is add some new rows to a table that already exists. I'd also like an "unseed" option to remove those rows when the package is uninstalled.
I'm unsure how to go about this? What is best practice?
Thanks
The simplest option is to create a seed class as usual and instruct users to run the db:seed
command with its --class[=CLASS]
option.
For example, your package could contain seed classes MyPackage\Seeds\Install
to add rows and MyPackage\Seeds\Remove
to remove them. Users of your package can run these seeds with:
php artisan db:seed --class="MyPackage\Seeds\Install"
php artisan db:seed --class="MyPackage\Seeds\Remove"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With