PHP

Understand and Implement Laravel Model Events

One of the most powerful functionalities in Laravel is the event. This feature enables all the triggers of various tangentially related functionality to occur throughout the life cycle of a model instance. Plus, events are always listening – meaning you don’t have to explicitly call them in the code to harness their powers. In this post, we’ll implement a sample Laravel model event listener.

Extracting Eloquent Queries to View Composers in Laravel

Whenever working with data using Laravel, it can be easy to write a few small Eloquent queries within your blade files to access the database. However, this practice can quickly spiral out of control if you're not careful, increasing query load time and destroying the performance of your application. In this post, I'll explain how to extract commonly used queries to a view composer so that they can be shared across multiple views that use different blade files.