Files
tbbank-new/database/seeders/Migrators/LoanOrdersMigrator.php
Mekan1206 76c05ebe7c Refactor ActivityLogModule and clean up seeders
- Adjusted indentation in ActivityLogModule methods for consistency.
- Simplified ActivityLogRepository class by removing unnecessary lines.
- Updated FillJsonData seeder to streamline the run method.
- Modified various Migrator classes to change JSON data paths for testing and added sequence reset statements for better database integrity.
2025-12-21 19:16:26 +05:00

30 lines
680 B
PHP

<?php
namespace Database\Seeders\Migrators;
use Illuminate\Support\Facades\DB;
use JsonMachine\Items;
class LoanOrdersMigrator
{
public function migrate(): void
{
DB::table('loan_orders')->truncate();
$path = database_path('data/tested/loan_orders.json');
$items = Items::fromFile($path);
foreach ($items as $id => $item) {
if (! $item) {
continue;
}
DB::table('loan_orders')->insert((array) $item);
}
DB::statement("SELECT setval('loan_orders_id_seq', (SELECT MAX(id) from loan_orders));");
DB::statement("SELECT nextval('loan_orders_id_seq');");
}
}