This post is the second one in a series of articles titled Laravel 8 Beginner Insights that reflect what I’ve learned while using Laravel 8 for a side project for the first time: While working on my side-project, a Clubhouse profile editor named Clubprofile.xyz, I found myself needing functionality that could prefix/postfix the string values in an array. As Microsoft writes in their documentation about Extension methods: Extension methods enable you to “add” methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type.
It is quite similar to extension methods, but unlike Extension Methods in C#, you can’t append functionality to every class.
Laravel provides a mechanism called Mixins; this allows you to code your macros in a separate class, that you can “mix into” your AppServiceProvider class (makes sense, huh?).
Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox.Explore