Files
tbbank-new/database/seeders/Migrators/OnlinePaymentsMigrator.php
Mekan1206 a5bc322170 Enhance MigrationController and ShieldSeeder for improved data migration and role management
- Added new migrators: ModelHasRolesMigrator and OnlinePaymentsMigrator to MigrationController.
- Introduced a test method in MigrationController to facilitate online payments migration.
- Updated ShieldSeeder to include role IDs for better role management and added new roles with specific IDs.
2025-12-21 20:58:10 +05:00

43 lines
1.6 KiB
PHP

<?php
namespace Database\Seeders\Migrators;
use App\Modules\CardOrder\Models\CardOrder;
use App\Modules\CardPinOrder\Models\CardPinOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
class OnlinePaymentsMigrator
{
public function migrate(): void
{
DB::table('online_payments')->truncate();
$path = database_path('data/tested/online_payment_histories.json');
$rawData = File::json($path);
foreach ($rawData as $data) {
if ($data['online_paymantable_type']) {
if ($data['online_paymantable_type'] == 'App\Models\Order\Card\Requisite\CardRequisite') {
continue;
}
$data['online_paymantable_type'] = match ($data['online_paymantable_type']) {
'App\Models\Order\Card\CardOrder' => CardOrder::class,
'App\Models\Order\Card\CardPin\CardPin' => CardPinOrder::class,
// 'App\Modules\SberPaymentOrder\Models\SberPaymentOrder' => SberPaymentOrder::class,
'App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder' => VisaMasterPaymentOrder::class,
'\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder' => VisaMasterPaymentOrder::class,
};
}
DB::table('online_payments')
->insert($data);
}
DB::statement("SELECT setval('online_payments_id_seq', (SELECT MAX(id) from online_payments));");
DB::statement("SELECT nextval('online_payments_id_seq');");
}
}