| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- use App\Models\Config;
- use Illuminate\Database\Migrations\Migration;
- return new class extends Migration
- {
- private static array $dropConfigs = ['paypal_username', 'paypal_password', 'paypal_secret', 'paypal_certificate'];
- private static array $newConfigs = ['paypal_client_id', 'paypal_client_secret'];
- /**
- * Run the migrations.
- */
- public function up(): void
- {
- if (Config::exists()) {
- foreach (self::$newConfigs as $config) {
- Config::insert(['name' => $config]);
- }
- foreach (self::$dropConfigs as $config) {
- Config::destroy(['name' => $config]);
- }
- }
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- foreach (self::$newConfigs as $config) {
- Config::destroy(['name' => $config]);
- }
- foreach (self::$dropConfigs as $config) {
- Config::insert(['name' => $config]);
- }
- }
- };
|