from django.db import models

# Create your models here.

class Departments(models.Model):
    dep_name = models.CharField(max_length=100) 
    dep_description = models.TextField()
    
    def __str__(self):                  # this function to show the dep_name at admin doctrors
        return self.dep_name

class Doctors(models.Model):
    doc_name = models.CharField(max_length=255)
    doc_spec = models.CharField(max_length=255)
    dep_name = models.ForeignKey(Departments, on_delete=models.CASCADE) # ForeignKey, If we delete from department records here will be deleted as well
    doc_image = models.ImageField(upload_to="doctors")

    def __str__(self):
        return 'Dr ' + self.doc_name + ' - (' + self.doc_spec +')'

class Booking(models.Model):
    p_name = models.CharField(max_length=255)   # p is for Patient
    p_phone = models.CharField(max_length=10)
    p_email = models.EmailField()
    doc_name = models.ForeignKey(Doctors, on_delete=models.CASCADE)
    booking_date = models.DateField()
    booked_on = models.DateField(auto_now=True) # only for the database