mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 02:09:07 +03:00
20 lines
749 B
TypeScript
20 lines
749 B
TypeScript
import BaseSeeder from '@ioc:Adonis/Lucid/Seeder';
|
|
import User from 'App/Models/User';
|
|
import { CourseFactory } from 'Database/factories';
|
|
|
|
export default class CourseSeeder extends BaseSeeder {
|
|
private User: typeof User;
|
|
|
|
public async run() {
|
|
this.User = User;
|
|
|
|
const teacher = await this.User.query()
|
|
.preload('roles', q => q.where('slug', 'teacher'))
|
|
.firstOrFail();
|
|
|
|
await (await CourseFactory.with('category').with('lessons', 3).create()).related('teacher').associate(teacher);
|
|
await (await CourseFactory.with('category').with('lessons', 2).create()).related('teacher').associate(teacher);
|
|
await (await CourseFactory.with('category').with('lessons', 1).create()).related('teacher').associate(teacher);
|
|
}
|
|
}
|