Skip to main content

Service layer

Services live in app/Models/Services/ and contain the core business logic. Controllers delegate to services — models handle persistence and relationships.

Core services

ServiceFilePurpose
RegistrationServiceServices/RegistrationService.phpComplete user registration flow
SessionServiceServices/SessionService.phpLogin/logout, token management
UsernameServiceServices/UsernameService.phpUsername validation (5-20 chars, alpha start, alphanumeric) and uniqueness
SubscriptionServiceServices/SubscriptionService.phpStripe subscription lifecycle, billing portal URLs
CouponServiceServices/CouponService.phpCoupon lookup by UID
FileServiceServices/FileService.phpFile storage and retrieval
NoteServiceServices/NoteService.phpLesson note creation with push notifications and emails
AddressServiceServices/AddressService.phpAddress storage, postcode search via Google Maps
CalendarServiceServices/CalendarService.phpGoogle Calendar sync (list, events, update)

Payment services

ServiceFilePurpose
StripeServiceServices/Payments/StripeService.phpFull Stripe integration (see Booking & Payments)
StripePaymentStatusServices/Payments/StripePaymentStatus.phpPayment status value object with 3D Secure checks
PaymentServiceInterfaceServices/Payments/PaymentServiceInterface.phpContract for payment providers

Search & availability services

ServiceFilePurpose
SearchServiceServices/v1/SearchService.phpTutor search with complex filtering (see Search)
AvailabilityServiceServices/v1/AvailabilityService.phpAvailable time slot calculation with calendar/travel conflicts

Review services

ServiceFilePurpose
TutorReviewServiceServices/TutorReviewService.phpReview creation, deletion, cached summaries, push notifications
LearnerReviewServiceServices/LearnerReviewService.phpLearner review submission with internal email notification

Google services

ServiceFilePurpose
GoogleMapsAPIServices/Google/GoogleMapsAPI.phpGeocoding and reverse geocoding via Google Maps
GoogleCalendarEventServices/Google/GoogleCalendarEvent.phpCalendar event value object
GoogleGeoCodeResultServices/Google/GoogleGeoCodeResult.phpGeocode result value object
GoogleReverseGeoCodeResultServices/Google/GoogleReverseGeoCodeResult.phpReverse geocode result with address parsing

Integration services

ServiceFilePurpose
TwilioServiceServices/Integrations/TwilioService.phpSMS verification via Twilio Verify V2
DailyMeetingServiceServices/DailyMeetingService.phpDaily.co video room management
PostcodeServiceServices/PostcodeService/PostcodeService.phpUK postcode lookup via postcodes.io (cached 3 months)

Versioning helpers

HelperFilePurpose
ServiceVersionModels/Helpers/ServiceVersion.phpResolves service class by API version with fallback
TransformerVersionModels/Helpers/TransformerVersion.phpResolves transformer class by API version with fallback
ServicePaginatorResponseModels/Helpers/ServicePaginatorResponse.phpWraps paginated results with metadata

Caching strategy

DataCache durationLocation
Tutor review summariesUntil end of dayTutorReviewService
Postcode coordinates3 monthsPostcodeService
BlackBox distance results2 daysBlackBox/Models/Distance

Transformers

Transformers live in app/Models/Transformers/v1/ and format model data into API response shapes. They’re called from controllers after services return data.

Available transformers

TransformerWhat it formats
BookingTransformerComplete booking with lesson, tutor, student, meeting, notes, receipt, activities, calendar events
TutorTransformerFull tutor profile (account, personal, education, verification, DBS, qualifications, addresses, subjects, availability, country)
TutorProfileTransformerPublic-facing tutor profile (basic info, bio, rating, social links, location)
SearchTransformerSearch results (tutor info, distance, experience, teaching info, pricing)
AvailableTimesTransformerAvailable time slots with pricing and lesson type options
CardTransformerPayment card (brand, last 4, expiry, default flag)
BankAccountTransformerBank account details
AddressTransformerAddress with country/currency, postcode search results
CouponTransformerCoupon details
FileTransformerFile (id, name, url)
NoteTransformerLesson note with attached file
LessonLocationTransformerLesson locations with enabled/disabled status
LessonPriceBreakdownTransformerPricing breakdown (lesson price, service fee, total, discount)
SocialLinksTransformerSocial platform links (connected + available)
TutorReviewTransformerReview summary with criteria ratings and paginated comments

BookingTransformer detail

The BookingTransformer is the most complex — it assembles data from across the system:
BookingTransformer::transform($booking)
├── Lesson info (state, type, times, address, subject, level, exam board)
├── Tutor info (profile, rating, hours taught, location, visibility)
├── Student/contact info (email, mobile)
├── Meeting info (join URLs)
├── Notes (student note, tutor note)
├── Receipt (pricing breakdown with commission)
├── Activities timeline
└── Calendar events
It uses many private helper methods: getLessonInfo(), getReceipt(), getAddress(), getTutorInfo(), getSubjectInfo(), getStudentContactInfo(), getMeeting(), etc.