mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 18:29:15 +03:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import Factory from '@ioc:Adonis/Lucid/Factory';
|
|
import Category from 'App/Models/Category';
|
|
import Contact from 'App/Models/Contact';
|
|
import Course from 'App/Models/Course';
|
|
import Lesson from 'App/Models/Lesson';
|
|
import User from 'App/Models/User';
|
|
|
|
export const ContactFactory = Factory.define(Contact, ({ faker }) => {
|
|
return {
|
|
phone_number: faker.phone.phoneNumber(),
|
|
};
|
|
}).build();
|
|
|
|
export const UserFactory = Factory.define(User, ({ faker }) => {
|
|
return {
|
|
first_name: faker.name.firstName(),
|
|
last_name: faker.name.lastName(),
|
|
login: `${faker.lorem.word(6)}${faker.datatype.number(10)}`,
|
|
email: faker.internet.exampleEmail(),
|
|
password: '12345',
|
|
};
|
|
})
|
|
.relation('contacts', () => ContactFactory)
|
|
.build();
|
|
|
|
export const LessonFactory = Factory.define(Lesson, ({ faker }) => {
|
|
return {
|
|
title: faker.lorem.sentence(2),
|
|
description: faker.lorem.sentence(5),
|
|
};
|
|
}).build();
|
|
|
|
export const CategoryFactory = Factory.define(Category, ({ faker }) => {
|
|
const title = faker.lorem.word(6);
|
|
return {
|
|
title: `${title[0].toUpperCase()}${title.slice(1)}`,
|
|
description: faker.lorem.sentence(5),
|
|
};
|
|
}).build();
|
|
|
|
export const CourseFactory = Factory.define(Course, ({ faker }) => {
|
|
return {
|
|
title: faker.lorem.sentence(3),
|
|
description: faker.lorem.sentence(5),
|
|
};
|
|
})
|
|
.relation('category', () => CategoryFactory)
|
|
.relation('lessons', () => LessonFactory)
|
|
// .relation('teacher', () => UserFactory)
|
|
.build();
|