text: from braintree import transaction
  from django.db import models
  from django.contrib.auth.models import User
  
  # Create your models here.
  
  
  class HeroSection(models.Model):
      name = models.CharField(max_length=200)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return self.name
  
  
  class HeroSectionImage(models.Model):
      hero = models.ForeignKey(
          HeroSection, related_name='images', on_delete=models.CASCADE)
      image = models.ImageField()
      title = models.CharField(max_length=200)
      description = models.CharField(max_length=300)
  
  class Category(models.Model):
      name = models.CharField(max_length=200, null=True, blank=True)
      description = models.TextField(null=True, blank=True)
      createdAt = models.DateTimeField(auto_now_add=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return str(self.name)
  
  
  class Product(models.Model):
      user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
      name = models.CharField(max_length=200, null=True, blank=True)
      image = models.ImageField(blank=True, null=False,
                                default='/placeholder.png')
      image2 = models.ImageField(null=True, blank=True)
      brand = models.CharField(max_length=200, null=True, blank=True)
      category = models.ForeignKey(Category,on_delete=models.SET_NULL, null=True)
      description = models.TextField(null=True, blank=True)
      rating = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      numReviews = models.IntegerField(null=True, blank=True, default=0)
      old_price = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      new_price = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      countInStock = models.IntegerField(null=True, blank=True, default=0)
      createdAt = models.DateTimeField(auto_now_add=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return self.name
  
      def clean(self):
          if not self.image:
              self.image = '/placeholder.png'
  
  
  class Review(models.Model):
      product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
      user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
      name = models.CharField(max_length=200, null=True, blank=True)
      rating = models.IntegerField(null=True, blank=True, default=0)
      comment = models.TextField(null=True, blank=True)
      createdAt = models.DateTimeField(auto_now_add=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return str(self.rating)
  
  class Order(models.Model):
      user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
      paymentMethod = models.CharField(max_length=200, null=True, blank=True)
      transaction_id = models.CharField(max_length=200, null=True, blank=True)
      taxPrice = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      shippingPrice = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      totalPrice = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      isPaid = models.BooleanField(default=False)
      paidAt = models.DateTimeField(auto_now_add=False, null=True, blank=True)
      isDelivered = models.BooleanField(default=False)
      deliveredAt = models.DateTimeField(
          auto_now_add=False, null=True, blank=True)
      createdAt = models.DateTimeField(auto_now_add=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return str(self.createdAt)
  
  
  class OrderItem(models.Model):
      product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
      order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
      user=models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
      name = models.CharField(max_length=200, null=True, blank=True)
      qty = models.IntegerField(null=True, blank=True, default=0)
      price = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      image = models.TextField(null=True, blank=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return str(self.name)
  
  
  class ShippingAddress(models.Model):
      order = models.OneToOneField(
          Order, on_delete=models.CASCADE, null=True, blank=True)
      name = models.CharField(max_length=200, null=True, blank=True)
      address = models.CharField(max_length=300, null=True, blank=True)
      city = models.CharField(max_length=200, null=True, blank=True)
      postalCode = models.CharField(max_length=200, null=True, blank=True)
      country = models.CharField(max_length=200, null=True, blank=True)
      state = models.CharField(max_length=200, null=True, blank=True)
      phone = models.CharField(max_length=16, null=True, blank=True)
      shippingPrice = models.DecimalField(
          max_digits=7, decimal_places=2, null=True, blank=True)
      _id = models.AutoField(primary_key=True, editable=False)
  
      def __str__(self):
          return str(self.address)
  