This commit is contained in:
2025-11-25 15:49:08 +03:30
parent 6f76b36a09
commit e6fb28b87e
4 changed files with 58 additions and 49 deletions
+15 -10
View File
@@ -235,23 +235,28 @@ export class DatabaseSeeder extends Seeder {
// 6. Create Categories (Farsi)
const categories = [
{ title: 'غذای اصلی', restId: zhivan?.id },
{ title: 'پیش غذا', restId: zhivan?.id },
{ title: 'دسر', restId: zhivan?.id },
{ title: 'نوشیدنی', restId: zhivan?.id },
{ title: 'غذای اصلی', restId: boote?.id },
{ title: 'پیش غذا', restId: boote?.id },
{ title: 'دسر', restId: boote?.id },
{ title: 'نوشیدنی', restId: boote?.id },
{ title: 'غذای اصلی', restaurant: zhivan },
{ title: 'پیش غذا', restaurant: zhivan },
{ title: 'دسر', restaurant: zhivan },
{ title: 'نوشیدنی', restaurant: zhivan },
{ title: 'غذای اصلی', restaurant: boote },
{ title: 'پیش غذا', restaurant: boote },
{ title: 'دسر', restaurant: boote },
{ title: 'نوشیدنی', restaurant: boote },
];
const createdCategories: Category[] = [];
for (const catData of categories) {
const existing = await em.findOne(Category, { title: catData.title, restId: catData.restId });
if (!catData.restaurant) continue;
const existing = await em.findOne(Category, {
title: catData.title,
restaurant: catData.restaurant,
});
if (!existing) {
const category = em.create(Category, {
title: catData.title,
restId: catData.restId,
restaurant: catData.restaurant,
isActive: true,
});
em.persist(category);