Free code snippets
Free code snippets, page 9
Small, self-contained patterns from real DEV3 products, each explained, with a live preview where it makes sense. Copy them into your project; commercial use is fine.
- 200
- snippets
- 7
- stacks
All snippets
Laravel · DatabaseApplicant pipeline state machineA backed enum with an allowed-transitions map and a locked mover that enforces rules, requires a reason for rejection and writes a history row.state-machineenumworkflow Laravel · DatabaseAppend-only points ledgerRecord loyalty points as immutable ledger rows with a running balance, an idempotency key and a locked member row, so totals can always be audited.ledgerloyaltypoints Laravel · APIsAPI resource with sparse fieldsetsLet API clients request only the fields they need with a fields query parameter, applied inside a Laravel JSON resource using a small trait.api-resourcejsonfieldsets WordPress · PaymentsAny-amount donation formA donation form with preset amounts, a custom amount field and strict server-side parsing into minor currency units.donationformsanitising Laravel · Queue jobsAffiliate commission jobA queued job that turns a paid order into one commission row with a tiered rate and a hold period, safe against duplicate dispatches.affiliatecommissionqueue Tailwind CSS · Dashboard widgetsAdmin stat cards with trend badgesA row of KPI cards showing a label, a large value and a coloured up or down trend badge with an accessible description.statskpibadge1 Tailwind CSS · ModalsAccessible modal with focus trapA modal dialog that traps keyboard focus, closes on Escape or backdrop click and returns focus to the trigger.modaldialogfocus-trap WordPress · NavigationAccessible mega-menu nav walkerA Walker_Nav_Menu subclass that renders disclosure buttons, aria-expanded state and Escape-to-close for dropdown menus.menuwalkeraria