2025_04_21_215352_add_cryptomus.php 558 B

12345678910111213141516171819202122232425
  1. <?php
  2. use App\Models\Config;
  3. use Illuminate\Database\Migrations\Migration;
  4. return new class extends Migration
  5. {
  6. private static array $configs = ['cryptomus_merchant_uuid', 'cryptomus_api_key'];
  7. public function up(): void
  8. {
  9. if (Config::exists()) {
  10. foreach (self::$configs as $config) {
  11. Config::insert(['name' => $config]);
  12. }
  13. }
  14. }
  15. public function down(): void
  16. {
  17. foreach (self::$configs as $config) {
  18. Config::destroy(['name' => $config]);
  19. }
  20. }
  21. };