Remove unused MorphToMany relationships from models and add CategoriesTableSeeder for category data population
This commit is contained in:
35
database/seeders/new/PropertiesTableSeeder.php
Normal file
35
database/seeders/new/PropertiesTableSeeder.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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}))
|
||||
");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user