forked from UKSOURCE/cms.hailearning.edu.vn
feat: Implement core admin panel functionalities including appointment, contact, and pricing management with associated models, controllers, views, and routes.
This commit is contained in:
74
models/contactSubmission.js
Normal file
74
models/contactSubmission.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
/**
|
||||
* Schema for Contact Form Submissions
|
||||
* Stores user inquiries from the contact form
|
||||
*/
|
||||
const contactSubmissionSchema = new mongoose.Schema(
|
||||
{
|
||||
name: {
|
||||
type: String,
|
||||
required: [true, "Name is required"],
|
||||
trim: true,
|
||||
maxlength: [100, "Name cannot exceed 100 characters"],
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: [true, "Email is required"],
|
||||
trim: true,
|
||||
lowercase: true,
|
||||
match: [/^\S+@\S+\.\S+$/, "Please enter a valid email"],
|
||||
},
|
||||
phone: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: "",
|
||||
},
|
||||
address: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: "",
|
||||
},
|
||||
date: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: "",
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: "",
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
enum: ["pending", "read", "replied", "archived"],
|
||||
default: "pending",
|
||||
},
|
||||
notes: {
|
||||
type: String,
|
||||
trim: true,
|
||||
default: "",
|
||||
},
|
||||
repliedAt: {
|
||||
type: Date,
|
||||
default: null,
|
||||
},
|
||||
ipAddress: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
userAgent: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
// Index for faster queries
|
||||
contactSubmissionSchema.index({ status: 1, createdAt: -1 });
|
||||
contactSubmissionSchema.index({ email: 1 });
|
||||
|
||||
module.exports = mongoose.model("ContactSubmission", contactSubmissionSchema);
|
||||
Reference in New Issue
Block a user