update seeder
This commit is contained in:
@@ -10,6 +10,7 @@ import { Restaurant } from '../modules/restaurants/entities/restaurant.entity';
|
||||
import { User } from '../modules/users/entities/user.entity';
|
||||
import { Permission, PermissionTitles } from '../common/enums/permission.enum';
|
||||
import { PaymentMethod } from '../modules/payments/entities/payment-method.entity';
|
||||
import { RestaurantPaymentMethod } from '../modules/payments/entities/restaurant-payment-method.entity';
|
||||
import { ShipmentMethod } from '../modules/restaurants/entities/shipment-method.entity';
|
||||
|
||||
export class DatabaseSeeder extends Seeder {
|
||||
@@ -206,6 +207,32 @@ export class DatabaseSeeder extends Seeder {
|
||||
const zhivan = await em.findOne(Restaurant, { slug: 'zhivan' });
|
||||
const boote = await em.findOne(Restaurant, { slug: 'boote' });
|
||||
|
||||
// 5.5. Create Restaurant Payment Methods
|
||||
const allRestaurants = [zhivan, boote].filter(Boolean) as Restaurant[];
|
||||
const allPaymentMethods = await em.find(PaymentMethod, { isActive: true });
|
||||
|
||||
for (const restaurant of allRestaurants) {
|
||||
if (!restaurant) continue;
|
||||
|
||||
for (const paymentMethod of allPaymentMethods) {
|
||||
const existing = await em.findOne(RestaurantPaymentMethod, {
|
||||
restaurant: { id: restaurant.id },
|
||||
paymentMethod: { id: paymentMethod.id },
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
const restaurantPaymentMethod = em.create(RestaurantPaymentMethod, {
|
||||
restaurant,
|
||||
paymentMethod,
|
||||
isActive: true,
|
||||
});
|
||||
em.persist(restaurantPaymentMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await em.flush();
|
||||
|
||||
// 6. Create Categories (Farsi)
|
||||
const categories = [
|
||||
{ title: 'غذای اصلی', restId: zhivan?.id },
|
||||
|
||||
Reference in New Issue
Block a user