2026_10_28_160000_create_recharge_method_logos.php 1016 B

12345678910111213141516171819202122
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Schema;
  6. return new class extends Migration {
  7. public function up(): void
  8. {
  9. Schema::create('recharge_method_logos', function (Blueprint $t) {
  10. $t->string('channel_type', 100)->primary(); $t->string('logo', 2048)->nullable(); $t->timestamps();
  11. });
  12. if (Schema::hasColumn('recharge_channel', 'logo')) {
  13. foreach (DB::table('recharge_channel')->where('data_type', 1)->whereNull('deleted_at')->whereNotNull('logo')->where('logo', '<>', '')->orderBy('sort')->orderBy('id')->get() as $channel) {
  14. DB::table('recharge_method_logos')->insertOrIgnore(['channel_type' => $channel->type, 'logo' => $channel->logo,
  15. 'created_at' => now(), 'updated_at' => now()]);
  16. }
  17. }
  18. }
  19. public function down(): void { Schema::dropIfExists('recharge_method_logos'); }
  20. };