This commit is contained in:
2026-01-07 12:13:45 +03:30
parent 27ebf4a7b6
commit f2284c103d
235 changed files with 180468 additions and 1 deletions
@@ -0,0 +1,31 @@
import { Cascade, Collection, Entity, OneToMany, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { AdminRole } from './adminRole.entity';
import { normalizePhone } from '../../utils/phone.util';
@Entity({ tableName: 'admins' })
export class Admin extends BaseEntity {
@Property({ nullable: true })
firstName?: string;
@Property({ nullable: true })
lastName?: string;
private _phone!: string;
@Property({ unique: true })
get phone(): string {
return this._phone;
}
set phone(value: string) {
this._phone = normalizePhone(value);
}
// Add the new role property
@OneToMany(() => AdminRole, adminRole => adminRole.admin, {
cascade: [Cascade.ALL],
orphanRemoval: true,
})
roles = new Collection<AdminRole>(this);
}