import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
import Image from './Image';

@Entity('orphanages')
export default class Orphanage {
    @PrimaryGeneratedColumn('increment')
    id: number;

    @Column({
        length: 50
    })
    name: string;

    @Column('decimal', { precision: 10, scale: 8 })
    latitude: number;

    @Column('decimal', { precision: 10, scale: 8 })
    longitude: number;

    @Column({
        length: 300
    })
    about: string;

    @Column({
        length: 300,
        nullable: true
    })
    instructions: string;

    @Column({
        length: 20
    })
    opening_hours: string;

    @Column()
    open_on_weekends: boolean;

    @Column({
        length: 15
    })
    phone: string;

    @OneToMany(() => Image, image => image.orphanage, {
        cascade: ['insert', 'update']
    })
    images: Image[];
}