Model Descriptions
Ad
Manages advertisements within the app. Stores client name, start/end dates, target URL, and status. Links to AdView to track views and Eligibility to define targeting rules.
AdView
Tracks user views or interactions with specific Ads. Links the Ad and the User, and records the timestamp of the click (clicked_at).
Affirmation
Manages text-based affirmations. Contains localized text (ar_text, en_text), VIP status, links to an Intention, and supports user favorites (polymorphic Favorite). Tracks user interactions via UserProfile -> affirmations_sent.
ArchiveUserAffirmations (DEPRECATED)
Archives affirmations sent to users, similar to ArchiveUserLetters. Tracks User, Affirmation, date/time, read/shared status, and associated Background. Includes filtering scopes.
ArchiveUserLetters (DEPRECATED)
Archives letters sent to users. Tracks the User, the Letter sent, the date/time sent, read status (read_at), shared status (shared_at), and if shared with a specific Background. Includes scopes for filtering (e.g., today's letters, read/unread, notifiable).
AudioAffirmation
Manages audio affirmations using Spatie Media Library. Contains localized text (ar_text, en_text), VIP/active status, links to an Intention, and supports user favorites (polymorphic Favorite). Tracks user interactions via UserProfile -> audio_affirmations_sent.
AudioAffirmationUser (Pivot) (DEPRECATED)
Pivot model managing the many-to-many relationship between User and AudioAffirmation.
Background
Manages background images for the application using Spatie Media Library. Stores image details, color theme (light/dark), opacity settings, activation status, VIP status, and whether it's a default or user-uploaded background (linked via user_profile_id). Includes media conversions for optimization and thumbnails.
BlacklistIps
e model for storing blacklisted IP addresses for users that have been blocked from the app. contains an IP address column.
CallbackLog
Logs callback information, from Apple IAP providers. Stores user ID, VIP subscription ID, transaction IDs, and detailed payload information (notification, renewal, transaction) as JSON.
Challenge
Defines challenges with localized names and descriptions, activation status, and related questions (ChallengeQuestion), logs (ChallengeLog), and notifications (ChallengeNotification). Can be associated with subscriptions (polymorphic) and notification templates.
ChallengeLog
Records user progress and answers within a specific Challenge. Links to the User, the ChallengeQuestion answered, the user's Subscription, the answer provided, and any notes.
ChallengeNotification
Stores notification messages associated with a specific Challenge. Includes localized messages and the number of days relative to the challenge for scheduling the notification.
ChallengeQuestion
Stores the questions associated with a Challenge. Contains localized question text and links back to the parent Challenge.
Country
Manages country data including name (localized), country code, phone code, and status. Provides relationships to users via UserProfile for location and nationality. Includes scope for active countries and specific logic for taxability (e.g., 'SA').
CronLog
Simple log model to record the execution of cron jobs, storing the cron_name.
CustomAffirmation
Stores affirmations created by users. Links to the User who created it and the associated Intention. Contains the affirmation text.
CustomNotificationTemplate
Appears to be a placeholder or base model intended to be linked polymorphically to NotificationTemplate. It doesn't contain specific fields itself in the provided snippet. just for nova
DeconstructionQuestion
Manages 'Subconscious Deconstruction' questions, similar to OpenProbabilityQuestion. Linked to an Intention, contains localized question text, VIP status, supports user favorites (polymorphic Favorite), and scheduling (ScheduledNotification),Tracks user interactions via UserProfile -> doconstructions_sent.
Device
Manages user device registration for push notifications. Stores FCM token, device ID, and uses a polymorphic relationship (userable) to link the device to a user model (likely User). Uses string IDs (UUIDs likely).
EducationalLevel
Defines educational levels (e.g., High School, Bachelor's) with localized names. Links to UserProfile to store user demographic data.
Eligibility
Defines eligibility rules for Ad targeting using a polymorphic relationship (eligibilitable). Allows ads to be targeted based on specific models and their IDs (e.g., target users with a certain Interest or Country).
Emotion
Represents emotions with localized names, an associated emoji URL, type, and color. Can be linked to an EmotionalMap and has related SubEmotion records.
EmotionalMap
Defines an "Emotional Map" feature with localized names/descriptions, activation status, and requirements (minimum days/logs). Links to associated EmotionalMapResult records and can trigger NotificationTemplates.
EmotionalMapLog
Logs user entries for an EmotionalMap subscription. Links to the User, the specific Subscription, the date, the primary Emotion logged, associated SubEmotions (many-to-many), EmotionReasons (many-to-many), and any notes.
EmotionalMapNotification
Stores notification messages associated with a specific EmotionalMap. Includes localized messages and an order field.
EmotionalMapResult (DEPRECATED)
Stores the results associated with an EmotionalMap. Links an Emotion with a percentage and localized result text for a specific map instance.
EmotionReason
Defines reasons associated with emotions, likely used in EmotionalMapLog. Contains localized names.
Favorite
Handles user favorites using a polymorphic relationship (favouritable). Allows users to mark various items (like Affirmation, Letter, Music, OpenProbabilityQuestion) as favorites.
Hobby
Defines hobbies with localized names. Manages the many-to-many relationship between users and hobbies via the UserHobby pivot model.
IncomeLevel
Defines income levels with localized names. Links to UserProfile to store user demographic data.
Intention
Represents user intentions or goals. Contains localized names, status, VIP status, and relationships to associated content like letters, affirmations (text and audio), and questions (deconstruction, open probability). Also links to users via UserProfile and can have associated Music.
IntentionHistory
Records the history of user intentions, linking a User to an Intention and storing start/end times.
Interest
Represents user interests with localized names (English and Arabic). Manages the many-to-many relationship between users and interests via the UserInterest pivot model.
Letter
Represents letters or messages associated with an Intention. Contains localized names/titles, body content, VIP status, and supports user favorites (polymorphic Favorite). Tracks user interactions via UserLetter,Tracks user interactions via UserProfile -> letters_sent.
Music
Manages music tracks, including localized titles, descriptions, artist name, and audio file details. Supports media uploads (cover image), sorting, activation status, and favorites (polymorphic).
Notification
Stores individual user notifications with title, body, and a polymorphic relationship (eventable) to link the notification to the specific event or model that triggered it (e.g., a new message, a subscription update).
NotificationSetting
Stores user-specific settings for different notification types. Links to the User and stores the notification type, preferred start_time, end_time, and reminders_per_day. Possible types include:
- Affirmation
- Letter
- OpenProbabilityQuestion
- DeconstructionQuestion
NotificationTemplate
Defines templates for sending notifications. Includes name, title, message, icon, scheduling information (scheduled_date), and a polymorphic relationship (typeable) to link templates to specific models (like Intention or VipSubscription) that trigger them. Tracks send counts and dates.
NotificationTemplateLog
Logs the history of sent notifications based on NotificationTemplate. Stores the title, message, count, last sent date, and links back to the parent NotificationTemplate.
OpenProbabilityQuestion
Manages 'Open Probability' or 'Possibility Recognition' questions, linked to an Intention. Contains localized question text, VIP status, and supports user favorites (polymorphic Favorite) and scheduling (ScheduledNotification),Tracks user interactions via UserProfile -> open_questions_sent.
Order
Represents a specific purchase transaction within the application. It links a User to the item purchased (item polymorphic relationship, e.g., a VipPackage) and records crucial details about the transaction. Key fields include a unique order number, the payment_method used (e.g., card, IAP, defined by OrderPaymentMethodEnum), the transaction status (e.g., pending, completed, failed), financial details (total_tax, total_discount, total, paid_amount, paid_currency, tax_type), payment gateway references (payment_reference_id, payment_card_type), In-App Purchase details (iap_order_id, iap_price, iap_product_id), timestamps (paid_at), and potentially metadata (meta). It also connects directly to the resulting VipSubscription if the order was for a VIP package.
ScheduledNotification
Manages the scheduling of various notification types (polymorphic messageable, e.g., Affirmation, Letter, OpenProbabilityQuestion). Stores the scheduled date/time, user, intention, last sent time, and queue processing time. Includes scopes for filtering by type. The main types managed are:
- Affirmation
- Letter
- OpenProbabilityQuestion
- DeconstructionQuestion
Setting
Manages application-wide settings stored as key-value pairs, such as privacy policy text, app store links, version numbers, and reminder limits. Handles localization for setting values.
SmsLog
Logs outgoing SMS messages. Stores the recipient phone number, message body, sent status, IP address, and blocked status.
SubEmotion (DEPRECATED)
Represents a more specific emotion category belonging to a main Emotion. Includes localized names and potentially course recommendation text and links based on the sub-emotion. Links to EmotionalMapLog via a pivot table.
Subscription
Handles user subscriptions to various features (polymorphic subscribable, e.g., EmotionalMap, Challenge). Tracks user, start date, status, daily action status, and notification preferences (notification_times array).
User
Represents the core user account model, managing authentication details (email, social login), device information (FCM token, type, OS), user roles, verification status, and relationships to profile, subscriptions, activities, etc. Includes logic for calculating user profile completion progress.
UserAffirmation (DEPRECATED)
Represents the instance of a text Affirmation sent to a User. Tracks the user, affirmation, intention, date/time, notification status, read/shared status, and associated Background. (Similar to UserLetter and potentially ArchiveUserAffirmations).
UserHobby (Pivot)
Acts as the pivot model managing the many-to-many relationship between User and Hobby. (Note: This model appears minimal, primarily serving the relationship definition).
UserInterest (Pivot)
Pivot model managing the many-to-many relationship between User and Interest. (Minimal model, primarily for relationship definition).
UserLetter (DEPRECATED)
Represents the instance of a Letter sent to a User. Tracks the user, the letter, the specific Intention it relates to, the date/time sent, notification status, read/shared status, and associated Background. (Note: This seems functionally similar to ArchiveUserLetters, possibly redundant or part of a different workflow).
UserProfile
Stores detailed user profile information extending the base User model, including personal details (DOB, gender, nationality), contact info (phone), demographic data (marital status, education, income), app preferences (language, background, reminders), and tracking for specific features like intentions and sent content (affirmations, letters).
UserVerification
Handles user email or phone verification tokens. Stores the user's email, the verification token, the associated User, and the verification status (pending/verified).
VipPackage
Defines the available VIP subscription plans or packages that users can purchase. Stores package details such as localized names (name_ar, name_en), a list of included features (features_data as JSON), the regular price (price), the duration in days (duration), In-App Purchase details like the IAP-specific price (iap_price) and the product identifier (iap_product_id), the number of free trial days offered (free_trial_days), and whether the package is currently active (is_active). It also includes logic to calculate applicable taxes and determine if a user is eligible for a free trial based on their history.
VipSubscription
Represents an individual user's active or past VIP subscription instance. It links a User to a specific VipPackage and the Order through which it was purchased. Key attributes include the subscription status (likely using VipSubscriptionStatusEnum), start and expiration dates (start_date, expire_date), duration, whether it's currently active (is_active), if it was a free trial (is_free), the type of subscription (type using VipSubscriptionTypesEnum), renewal details (renewal_at, renewal_price), and detailed In-App Purchase information (iap_original_transaction_id, iap_original_order_id, iap_status, expired_at). It also maintains a link to its historical changes via VipSubscriptionHistory.
VipSubscriptionHistory
Serves as an audit log tracking significant events in the lifecycle of a VipSubscription. History records are typically created before a subscription is renewed or expired, capturing the state prior to the change. Each entry stores the associated vip_subscription_id, user_id, order_id (if applicable), the state details at that time (start_date, duration, day), the event type that triggered the record (type using VipSubscriptionTypesEnum, e.g., RENEWAL, EXPIRED), and relevant IAP details (iap_price, iap_product_id, iap_transaction_id). This provides a historical trail of subscription changes.