35 lines
958 B
PHP
35 lines
958 B
PHP
<?php
|
|
|
|
namespace Database\Seeders\New;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PropertiesTableSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
$datas = json_decode(File::get('database/data/properties.json'));
|
|
$table = 'attributes';
|
|
|
|
DB::table($table)->truncate();
|
|
|
|
foreach ($datas as $data) {
|
|
DB::table($table)->insertOrIgnore([
|
|
'id' => $data->id,
|
|
'slug' => $data->code,
|
|
'name' => str_replace('"tm"', '"tk"', $data->name),
|
|
'description' => $data->description,
|
|
'type' => 'text',
|
|
'created_at' => $data->created_at,
|
|
'updated_at' => $data->updated_at,
|
|
]);
|
|
}
|
|
|
|
DB::statement("
|
|
SELECT setval('{$table}_id_seq', (SELECT MAX(id) from {$table}))
|
|
");
|
|
}
|
|
} |