2023_06_04_224713_update_paypal.php 914 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use App\Models\Config;
  3. use Illuminate\Database\Migrations\Migration;
  4. return new class extends Migration
  5. {
  6. private static array $dropConfigs = ['paypal_username', 'paypal_password', 'paypal_secret', 'paypal_certificate'];
  7. private static array $newConfigs = ['paypal_client_id', 'paypal_client_secret'];
  8. public function up(): void
  9. {
  10. if (Config::exists()) {
  11. foreach (self::$newConfigs as $config) {
  12. Config::insert(['name' => $config]);
  13. }
  14. foreach (self::$dropConfigs as $config) {
  15. Config::destroy(['name' => $config]);
  16. }
  17. }
  18. }
  19. public function down(): void
  20. {
  21. foreach (self::$newConfigs as $config) {
  22. Config::destroy(['name' => $config]);
  23. }
  24. foreach (self::$dropConfigs as $config) {
  25. Config::insert(['name' => $config]);
  26. }
  27. }
  28. };