This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
namespace Database\Seeders;
use Exception;
use File;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class FavouriteTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$this->seedOldData();
}
/**
* Seed old postshop data
*/
public function seedOldData(): void
{
$table = 'favorites';
DB::table($table)->delete();
$datas = collect(json_decode(File::get('database/data/favorites.json')));
foreach ($datas as $data) {
try {
DB::table($table)->insert([
'id' => $data->id,
'user_id' => $data->user_id,
'product_id' => $data->product_id,
'created_at' => $data->created_at,
'updated_at' => $data->updated_at,
]);
} catch (Exception $e) {
info(['Ignore error', $e->getMessage()]);
}
}
DB::statement("
SELECT setval('{$table}_id_seq', (SELECT MAX(id) from {$table}))
");
}
}