Skip to content

Domains ​

sh
npx megh scaffold:domain ecommerce            # checklist of the domain's templates
npx megh sc:domain ecommerce -y --resource    # every template, as REST resources
npx megh sc:domain pos --only product,sale,sale_item --factory
npx megh sc:domain medical --migrations-only
npx megh sc:domain                            # pick a domain

scaffold:domain writes a migration for each template of a domain, in the order their foreign keys need, and then a model for each (join tables have none). Templates a foreign key points to from another domain are included, such as common/user for ecommerce/customer.

Domains share tables: ecommerce and pos both have products and customers, and hr and medical both have departments. Scaffolding a second domain reuses the tables and models already there.

OptionDescription
--only <list>Only these templates, e.g. product,order,order_item
--allEvery template, without the checklist
--resourceGenerate REST resources (DTOs, service, controller), not just models
--migrations-onlyOnly write the migrations
--factoryAlso write a factory for each model
--no-depsDon't create the tables foreign keys point to
-f, --forceRegenerate the models (and resources) that already exist
-y, --yesDon't prompt: every template (or --only), with their dependencies

Scaffold a single template with make:model --template, and add your own domains in .megh/templates/.

Built-in Templates ​

Every table also has an id, created_at and updated_at, except join tables, which have neither. Run npx megh templates <domain> for the same list in the terminal.

Common common ​

Users, roles, categories and other tables most apps share.

TemplateTableColumns
userusers (soft deletes)name, email, password, email_verified_at, remember_token, is_active, last_login_at
rolerolesname, slug, description
permissionpermissionsname, group, description
user_roleuser_roles (join table)user_id, role_id
role_permissionrole_permissions (join table)role_id, permission_id
categorycategoriesparent_id, name, slug, description, image, sort_order, is_active
tagtagsname, slug
addressaddressesaddressable_type, addressable_id, label, address_line1, address_line2, city, state, postal_code, country, latitude, longitude, is_default
attachmentattachmentsattachable_type, attachable_id, name, path, disk, mime_type, size
api_keyapi_keysuser_id, name, prefix, key_hash, last_used_at, expires_at, revoked_at
settingsettingsname, value, group

E-commerce ecommerce ​

An online store: catalog, carts, orders and payments.

TemplateTableColumns
brandbrandsname, slug, logo, description, website, is_active
productproducts (soft deletes)category_id, brand_id, name, slug, sku, description, price, compare_at_price, cost, stock, weight, status, is_featured
product_variantproduct_variantsproduct_id, sku, name, price, stock, options, image
product_tagproduct_tags (join table)product_id, tag_id
customercustomersuser_id, first_name, last_name, email, phone, accepts_marketing
cartcartscustomer_id, session_id, currency, status
cart_itemcart_itemscart_id, product_id, product_variant_id, quantity, price
couponcouponscode, description, discount_type, value, min_order_amount, max_uses, used_count, starts_at, ends_at, is_active
orderorderscustomer_id, coupon_id, number, status, subtotal, discount, tax, shipping_total, total, currency, shipping_address, billing_address, placed_at, notes
order_itemorder_itemsorder_id, product_id, product_variant_id, name, sku, quantity, price, discount, total
paymentpaymentsorder_id, method, provider, transaction_id, amount, currency, status, paid_at
shipmentshipmentsorder_id, carrier, tracking_number, status, shipped_at, delivered_at
reviewreviewsproduct_id, customer_id, rating, title, comment, is_approved
wishlistwishlistscustomer_id, product_id

Point of sale pos ​

Shops and tills: outlets, shifts, sales, purchases and stock.

TemplateTableColumns
outletoutletsname, code, phone, email, address_line1, address_line2, city, state, postal_code, country, is_active
registerregistersoutlet_id, name, is_active
shiftshiftsregister_id, user_id, opened_at, closed_at, opening_cash, closing_cash, expected_cash, status, notes
customercustomersname, email, phone, loyalty_points, notes
suppliersuppliersname, contact_name, email, phone, address_line1, address_line2, city, state, postal_code, country, tax_number, is_active
tax_ratetax_ratesname, rate, is_inclusive, is_active
productproductscategory_id, name, sku, barcode, price, cost, stock, reorder_level, tax_rate_id, is_active
salesalesoutlet_id, register_id, shift_id, customer_id, user_id, number, subtotal, discount, tax, total, paid_amount, change_amount, status, sold_at
sale_itemsale_itemssale_id, product_id, name, quantity, price, discount, tax, total
sale_paymentsale_paymentssale_id, method, amount, reference
purchasepurchasessupplier_id, outlet_id, number, status, subtotal, tax, total, ordered_at, received_at, notes
purchase_itempurchase_itemspurchase_id, product_id, quantity, unit_cost, total
stock_movementstock_movementsproduct_id, outlet_id, user_id, type, quantity, reference, notes

Medical medical ​

Clinics and hospitals: patients, doctors, appointments and records.

TemplateTableColumns
departmentdepartmentsname, code, description, phone, is_active
doctordoctorsuser_id, department_id, first_name, last_name, email, phone, specialization, license_number, consultation_fee, is_active
patientpatients (soft deletes)mrn, first_name, last_name, gender, date_of_birth, phone, email, address_line1, address_line2, city, state, postal_code, country, blood_group, allergies, emergency_contact_name, emergency_contact_phone
appointmentappointmentspatient_id, doctor_id, department_id, scheduled_at, duration_minutes, status, reason, notes
medical_recordmedical_recordspatient_id, doctor_id, appointment_id, visit_date, chief_complaint, diagnosis, treatment, vitals, notes
medicationmedicationsname, generic_name, form, strength, manufacturer, price, stock, is_active
prescriptionprescriptionspatient_id, doctor_id, medical_record_id, medication_id, dosage, frequency, duration, quantity, instructions, prescribed_at
lab_testlab_testspatient_id, doctor_id, name, code, status, result, normal_range, unit, ordered_at, completed_at
insuranceinsurancespatient_id, provider, policy_number, group_number, coverage_percent, valid_from, valid_until, is_active
invoiceinvoicespatient_id, appointment_id, insurance_id, number, subtotal, discount, tax, total, paid_amount, status, issued_at, due_date

Construction construction ​

Building projects: sites, contractors, work orders, materials and budgets.

TemplateTableColumns
clientclientsname, company, email, phone, address_line1, address_line2, city, state, postal_code, country
projectprojects (soft deletes)client_id, manager_id, name, code, description, status, budget, start_date, end_date, address_line1, address_line2, city, state, postal_code, country
sitesitesproject_id, supervisor_id, name, address_line1, address_line2, city, state, postal_code, country, latitude, longitude, is_active
contractorcontractorsname, company, trade, email, phone, license_number, address_line1, address_line2, city, state, postal_code, country, rating, is_active
work_orderwork_ordersproject_id, site_id, contractor_id, assigned_to_id, title, description, priority, status, due_date, completed_at, estimated_cost, actual_cost
materialmaterialsname, sku, unit, unit_cost, quantity_on_hand, reorder_level, supplier
equipmentequipmentsite_id, name, code, category, serial_number, status, purchase_date, purchase_cost
timesheettimesheetsuser_id, project_id, work_order_id, date, hours, overtime_hours, status, notes
inspectioninspectionsproject_id, site_id, inspector_name, type, scheduled_at, inspected_at, result, notes
change_orderchange_ordersproject_id, requested_by_id, number, title, description, amount, days_impact, status, approved_at
budget_itembudget_itemsproject_id, category, description, budgeted_amount, actual_amount, notes

Marketing marketing ​

Campaigns, leads, contacts, segments and email.

TemplateTableColumns
campaigncampaignsowner_id, name, slug, type, status, budget, spent, starts_at, ends_at, description
contactcontactsfirst_name, last_name, email, phone, company, job_title, source, country, status
leadleadscontact_id, campaign_id, owner_id, name, email, phone, company, source, status, score, notes
segmentsegmentsname, description, rules, is_dynamic
contact_segmentcontact_segments (join table)contact_id, segment_id
email_templateemail_templatesname, subject, body, from_name, from_email, is_active
subscribersubscribersemail, name, status, source, subscribed_at, unsubscribed_at, ip_address
landing_pagelanding_pagescampaign_id, title, slug, content, meta_title, meta_description, status, published_at, views, conversions
utm_linkutm_linkscampaign_id, url, utm_source, utm_medium, utm_campaign, utm_term, utm_content, short_code, clicks

Real estate real-estate ​

Properties, listings, agents, tenants, leases and rent.

TemplateTableColumns
agentagentsuser_id, first_name, last_name, email, phone, license_number, agency, commission_rate, avatar, is_active
propertyproperties (soft deletes)agent_id, title, slug, description, type, status, address_line1, address_line2, city, state, postal_code, country, latitude, longitude, bedrooms, bathrooms, area, area_unit, lot_size, year_built, price, currency, is_featured
unitunitsproperty_id, unit_number, floor, bedrooms, bathrooms, area, rent, status
amenityamenitiesname, slug, icon, category
property_amenityproperty_amenities (join table)property_id, amenity_id
listinglistingsproperty_id, agent_id, type, price, currency, status, listed_at, expires_at, description, views
tenanttenantsuser_id, first_name, last_name, email, phone, date_of_birth, national_id, employer, monthly_income, emergency_contact_name, emergency_contact_phone
leaseleasesunit_id, tenant_id, start_date, end_date, rent_amount, deposit_amount, billing_day, status, terms, signed_at
rent_paymentrent_paymentslease_id, amount, due_date, paid_at, method, reference, status, late_fee
inquiryinquiriesproperty_id, listing_id, agent_id, name, email, phone, message, status
viewingviewingsproperty_id, inquiry_id, agent_id, scheduled_at, status, feedback
maintenance_requestmaintenance_requestsunit_id, tenant_id, title, description, priority, status, reported_at, resolved_at, cost

HR hr ​

Employees, departments, attendance, leave and payroll.

TemplateTableColumns
departmentdepartmentsname, code, description, is_active
positionpositionsdepartment_id, title, description, min_salary, max_salary
employeeemployees (soft deletes)user_id, department_id, position_id, employee_number, first_name, last_name, email, phone, gender, date_of_birth, hire_date, employment_type, salary, status, address_line1, address_line2, city, state, postal_code, country
attendanceattendancesemployee_id, date, check_in, check_out, status, hours, notes
leave_typeleave_typesname, code, days_per_year, is_paid
leave_requestleave_requestsemployee_id, leave_type_id, approved_by_id, start_date, end_date, days, reason, status, approved_at
payrollpayrollsemployee_id, period_start, period_end, basic_salary, allowances, deductions, tax, net_pay, status, paid_at

CRM crm ​

Accounts, contacts, deal pipelines and activities.

TemplateTableColumns
accountaccountsowner_id, name, industry, website, phone, email, address_line1, address_line2, city, state, postal_code, country, annual_revenue, employee_count, status
contactcontactsaccount_id, owner_id, first_name, last_name, email, phone, job_title, notes
pipelinepipelinesname, is_default, sort_order
pipeline_stagepipeline_stagespipeline_id, name, probability, sort_order, is_won, is_lost
dealdealsaccount_id, contact_id, pipeline_id, pipeline_stage_id, owner_id, title, amount, currency, expected_close_date, status, closed_at, lost_reason
activityactivitiesuser_id, account_id, contact_id, deal_id, type, subject, description, due_at, completed_at

Education education ​

Schools and courses: students, teachers, enrollments and grades.

TemplateTableColumns
teacherteachersuser_id, staff_number, first_name, last_name, email, phone, specialization, hire_date, is_active
studentstudentsuser_id, student_number, first_name, last_name, email, phone, gender, date_of_birth, admission_date, status, address_line1, address_line2, city, state, postal_code, country
coursecoursesteacher_id, code, title, description, credits, level, capacity, price, status, starts_at, ends_at
enrollmentenrollmentsstudent_id, course_id, enrolled_at, status, progress, completed_at
gradegradesenrollment_id, assessment, score, max_score, letter, weight, graded_at, remarks

Logistics logistics ​

Warehouses, vehicles, drivers and deliveries.

TemplateTableColumns
warehousewarehousesname, code, address_line1, address_line2, city, state, postal_code, country, latitude, longitude, phone, capacity, is_active
vehiclevehicleswarehouse_id, plate_number, type, make, model, year, capacity_kg, status
driverdriversuser_id, vehicle_id, first_name, last_name, phone, email, license_number, license_expires_at, status
deliverydeliverieswarehouse_id, vehicle_id, driver_id, tracking_number, recipient_name, recipient_phone, address_line1, address_line2, city, state, postal_code, country, latitude, longitude, weight, status, scheduled_at, delivered_at, proof_url, notes
tracking_eventtracking_eventsdelivery_id, status, location, latitude, longitude, occurred_at, notes

Released under the MIT License.