[update]: model class methods

This commit is contained in:
VivianDee
2025-03-28 10:11:44 +01:00
parent ad39b1c75c
commit bc8f8e2cdd
6 changed files with 30 additions and 33 deletions
+8 -1
View File
@@ -11,6 +11,13 @@ class Customer(db.Model):
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
@classmethod
def is_eligible(cls, customer_id):
customer = cls.query.filter_by(id=customer_id).first()
if not customer:
return False, "Customer not found"
return True, "Customer is eligible"
def __repr__(self):
return f'<Customer {self.id}>'
return f'<Customer {self.id}>'