from django.db import models


class MenuItem(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField()
    image=models.ImageField(upload_to='menu_image/')
    price=models.DecimalField(max_digits=5,decimal_places=2)
    category=models.ManyToManyField('category',related_name='item')


    def __str__(self):
        return self.name


class Category(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name


class OrederModel(models.Model):
    created_on=models.DateTimeField(auto_now_add=True)
    price=models.DecimalField(max_digits=5,decimal_places=2)
    items=models.ManyToManyField('MenuItem',related_name='order',blank=True)
    name = models.CharField(max_length=80 ,blank=True)
    email=models.EmailField(max_length=50,blank=True)
    street = models.CharField(max_length=80 ,blank=True)
    city= models.CharField(max_length=80 ,blank=True)
    state= models.CharField(max_length=80 ,blank=True)
    zip_code= models.IntegerField(blank=True, null=True)
    


    def __str__(self):
        return f'Order:{self.created_on.strftime("%b%d%I: %M %p")}'        


