mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
feat: added duration column to lesson
This commit is contained in:
parent
be2f05a780
commit
1a9bddd0d3
@ -19,6 +19,9 @@ export default class Lesson extends BaseModel {
|
||||
@column()
|
||||
public description: string;
|
||||
|
||||
@column()
|
||||
public duration: string;
|
||||
|
||||
@belongsTo(() => Course, {
|
||||
foreignKey: 'course_id',
|
||||
})
|
||||
|
||||
@ -75,6 +75,7 @@ export default class LessonRepository {
|
||||
const lesson = await this.Lesson.create({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
duration: data.duration.toFormat('HH:mm:ss'),
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@ export default class CreateLessonValidator {
|
||||
course_id: schema.string({}, [rules.exists({ table: 'courses', column: 'id' })]),
|
||||
title: schema.string({}, [rules.maxLength(255)]),
|
||||
description: schema.string(),
|
||||
duration: schema.date({ format: 'HH:mm:ss' }),
|
||||
video_url: schema.string({}, [rules.url()]),
|
||||
materials: schema.array.optional().members(
|
||||
schema.file({
|
||||
|
||||
@ -15,6 +15,7 @@ import Lesson from 'App/Models/Lesson';
|
||||
import LessonContent from 'App/Models/LessonContent';
|
||||
import Role from 'App/Models/Role';
|
||||
import User from 'App/Models/User';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const makeFakeUser = (faker: Faker.FakerStatic, loginPrefix?: string) => {
|
||||
return {
|
||||
@ -62,6 +63,11 @@ export const LessonFactory = Factory.define(Lesson, ({ faker }) => {
|
||||
return {
|
||||
title: `Lesson #${faker.datatype.number(200)}`,
|
||||
description: faker.lorem.sentence(5),
|
||||
duration: DateTime.fromObject({
|
||||
hour: faker.datatype.number(2),
|
||||
minute: faker.datatype.number({ min: 30, max: 59 }),
|
||||
second: 0,
|
||||
}).toFormat('HH:mm:ss'),
|
||||
};
|
||||
})
|
||||
.relation('content', () => LessonContentFactory)
|
||||
|
||||
@ -9,6 +9,7 @@ export default class Lessons extends BaseSchema {
|
||||
table.string('course_id', 21).unsigned().references('courses.id').onDelete('CASCADE');
|
||||
table.string('title').notNullable();
|
||||
table.string('description');
|
||||
table.time('duration').notNullable();
|
||||
table.timestamp('created_at', { useTz: true });
|
||||
table.timestamp('updated_at', { useTz: true });
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user