Programming by wishful thinking @aarondfrancis
Programming by wishful thinking  @aarondfrancis
Uploaded August 2025 | Updated September 2026, 19 minutes ago
What if your code could read the way you wish the framework worked? I'll show you how I built a powerful Laravel helper for finding all models that use a given trait starting with a made-up interface and ending with a flexible reflection-based collection.

Follow me:
Twitter: twitter.com/aarondfrancis
LinkedIn: linkedin.com/in/aarondfrancis
Website: aaronfrancis.com - find articles, podcasts, courses, and more.

Chapters:
00:00 - Programming by wishful thinking
00:16 - The 'ModelsThat:useTrait' idea
00:47 - The hasEmbedding trait pattern
01:31 - Abstract methods for embeddings
02:29 - Applying the trait to different models
03:13 - Trait-provided relationships and scopes
03:54 - Writing the embeddings:create command
04:44 - Starting the helper: modelsThatUseTrait
06:00 - Scanning files and resolving class names
07:02 - Converting paths to PSR-4 class names
08:03 - Using ReflectionClass to inspect traits
09:00 - Filtering models by trait usage
10:12 - Returning class names as a collection
11:00 - Verifying the helper works
11:16 - Next step: creating
Programming by wishful thinkingOffline-first, multiplayer SQLiteLivecoding: create a podcast from YouTube videosOpen source workBuilding a new Laravel dev runner (as a TUI)Laravel Serializable Closure: serialize the unserializableI made up this Laravel feature… then built itThe Music Makers Podcast - 011 - Dads: Be DoersCode tip: clean up after yourself (and a seltzer review)Distributed SQLite with Litestream and LiteFSSpeed up your Inertia.js website with these 7 tacticsThe Music Makers Podcast - 042 - Breaking the Chain
Aaron Francis |

Programming by wishful thinking

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER