28 lines
562 B
PHP
28 lines
562 B
PHP
<?php
|
|
|
|
namespace Database\Seeders\Migrators;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
use JsonMachine\Items;
|
|
|
|
class LoanOrdersMigrator
|
|
{
|
|
public function migrate(): void
|
|
{
|
|
DB::table('loan_orders')->truncate();
|
|
|
|
$path = database_path('data/nurmuhammetsdb/loan_orders.json');
|
|
|
|
$items = Items::fromFile($path);
|
|
|
|
foreach ($items as $id => $item) {
|
|
if (! $item) {
|
|
continue;
|
|
}
|
|
|
|
DB::table('loan_orders')->insert((array) $item);
|
|
}
|
|
}
|
|
}
|