Skip to Content

Key Eloquent Models

The Portal has 133 Eloquent models in app/Models/. This document covers the most important ones. All models map to tables in the shared MySQL database (also used by API v1 and API v2).

Core Models

User (app/Models/User.php)

The central model for all platform users — students, landlords/agents, moderators, admins, operators, and B2B users. Extends Laravel Authenticatable.

Key fields: id, name, email, role (integer), company_name, city, contact_no, image, last_seen, session_count, status

Traits: HasApiTokens, Notifiable, CompanyScope

Key relationships:

  • houses() — Houses owned/managed by this agent (hasMany House)
  • likedHouses() / allLikedHouses() — Student’s liked houses
  • documents() — Agent documents (hasMany Agent_document)
  • chatRooms() — Chat rooms as tenant
  • agentChatRooms() — Chat rooms as agent
  • contract() — Contract memberships (hasMany Contract_member)
  • viewingRequest() — Viewing requests
  • rating() — User rating (hasOne Ratings_user)
  • propertyOperator() — Linked property operator (matched by company_name)
  • brandAmbassador() — Brand ambassador record
  • huddleContract() — Huddle contract
  • moderations() — Chat moderations (for moderator users)
  • superAgentStatus() — Super agent status
  • userSessions() — Login sessions

Scopes: active(), whereIsModerator(), whereIsOperator(), withHouseCount()

InternalUser (app/Models/InternalUser.php)

Separate user model for Housr staff. Uses the internal_users table. Powers the permission system.

Key relationships:

  • roles() — Many-to-many with Role via internal_role_user

Methods: hasRole($role), hasPermission($permission)

House (app/Models/House.php)

Property listings. Uses soft deletes.

Key relationships:

  • agent() — The landlord/agent who owns this house (hasOne User)
  • liked_houses() / disliked_houses() — User engagement
  • viewing_requests() — Viewing requests for this house
  • booking_slots() — Available viewing time slots
  • contract() / activeContract() — Tenancy contracts
  • propertyOperator() — The property operator company
  • futureAvailabilities() — Future availability dates
  • boost() — Active boost credits
  • environment() — Environment/region
  • housrPlus() — Housr Plus listing flag
  • houses_viewed() — View tracking

Property_operator (app/Models/Property_operator.php)

Companies that manage properties. Supports a parent-child hierarchy for subsidiaries. Uses soft deletes.

Key relationships:

  • users() — All users in this company (matched by company_name)
  • houses() — All houses managed by this operator
  • parent() / children() — Company hierarchy
  • propertyOperatorVerification() — Verification status

Contract (app/Models/Contract.php)

Tenancy agreements linking houses to tenants.

Key relationships:

  • house() — The house under contract
  • contract_members() — Tenants on this contract (hasMany Contract_member)
  • landlord_rating() — Rating for the landlord on this contract

Enquiry (app/Models/Enquiry.php)

Deprecated — Use Viewing_request instead. Legacy enquiry model linking chat rooms to houses.

Engagement & Communication Models

ModelPurpose
Viewing_requestStudent viewing requests for houses
Booking_slot / Booked_slotViewing time slot availability and bookings
Chat_roomChat conversations between tenants and agents
Chat_room_memberMembers of a chat room
Chat_room_moderationModerator assignments to chat rooms
MessageChat messages (Firebase sync)
Liked_house / Disliked_houseStudent house preferences
House_viewedHouse view tracking

Events & Perks Models

ModelPurpose
EventEvents with status, access type, schedule
EventTicketIssued tickets for events
EventRSVPRSVP responses (going/interested/not_going)
EventUserApplicationApplication-based event access requests
EventExclusiveUserUsers with exclusive event access
PerkStudent perks/discounts
PerkCodeRedeemable perk codes
Perk_redeemed / Perk_code_redeemedRedemption tracking
PerkPartnerPartner companies providing perks
PerkExclusive / PerkTag / PerkTokenPerk metadata
Freebie / FreebieRedemptionFree items/offers

Bills & Payments Models

ModelPurpose
BillHouseHouses enrolled in bills
BillRegionRegional bill configuration
BillTenantTenant bill assignments
Bills_requestBill service requests
BillsIncludedAgent / BillsIncludedPriceBill pricing details
Boost_creditActive boost credits on houses
Boost_credit_priceBoost credit pricing tiers
Boost_transactionBoost purchase transaction records
CommissionB2B partner commissions

Administration Models

ModelPurpose
RoleInternal roles (table: internal_roles)
PermissionInternal permissions (table: internal_permissions)
CitySupported cities
UniversityUniversities in supported cities
EnvironmentDeployment environments/regions
Feature_flagRuntime feature flags
Global_variableSystem-wide configuration values
AdvertIn-app advertisements
Notification / Notification_log / Notification_openPush notification management
Drop / Drop_openNotification drops and engagement tracking

Content & Moderation Models

ModelPurpose
Moderation_noteNotes on moderated content
Moderation_ratingRatings for moderation quality
Ratings_student / Ratings_landlord / Ratings_userRating records
Ratings_dispute / Ratings_periodRating dispute handling
MaintenanceMaintenance requests
DocumentUploaded documents
User_noteNotes attached to user profiles

Naming Convention

Models use a mix of naming styles (legacy inconsistency):

  • Snake_case: House_change, Chat_room, Liked_house (older models)
  • PascalCase: InternalUser, BillRegion, EventTicket (newer models)

Both styles map to their respective database tables. Some models explicitly set protected $table when the table name does not follow Laravel’s convention.

Last updated on