A Meetup With Insight
Web Artisans Discussing The Intricacies Of Laravel
In our December meetup, the community discussed Laravel Observers. Imagine that you are controlling creating, retrieving, updating, deleting process while dealing with the database, not just that but you also can control once the process is finished. This can be done through with powerful events know as Observers.
An observer watches for specific things that happen within eloquent such as saving, saved, deleting, deleted. Why use Observers? Keeps the controllers lean. Using observers will allow controllers to do what they’re supposed to do. Receive requests and return responses. By using observers, you are handing more of the logic over to the model layer which is generally seen to be good practice nowadays. Maintainable code. By abstracting some of your logic into observers, you are organizing your code base and defining design standards which will be more easily understood by the developers working on the code base in the future. Provides reusable code by avoiding repeating yourself, you minimize bugs and localize them.
To provide you a perspective, imagine your application is growing, and you have to listen to most of the above events in your model, listening to the events within the model will make your model very big and messy of course.
Using model observers, you can group all your events into a single class. All method names in the observer class will reflect on the event you are listening to.
A peek inside our brilliant journey so far.
Read what our brilliant volunteers have to say.
It’s my responsibility to give back to community by sharing all knowledge I have, and also I want to make real connections with Laravel developers. 🙂
Shrirang Pramod JoshiPune
Getting to know the community better. I personally work on Laravel from the past 2 years and would like to contribute towards the community, and contribute to bring Laracon to India
LaravelLive is my first ever meetup event which i discovered by myself without any connection, and its really happy to see 3rd year of it. I would be feeling proud to take this community to the level it deserves to be.
1st thing is awareness about the community and to spread it, after that to share all the knowledge which I have obtained through my experience, and gain more in return