Eloquent helper functions, filters and mutators

I have been looking through the internet how I can make my coding more efficient specially when using Eloquent ORM. Eloquent returns a collection that can be filtered using various helper functions.

I would say how I can make my programming skills be more “functional” instead of the traditional for each loop. Check the link out for using helper functions once collection has been returned.


I will also add Accessors/Mutators basically when you set or access a field value , it will automatically returns a different format. For basic example, $users->firstname original value is “Sarah” if you used an accessor function defined in your model, you can automatically make the value apply any function such as strtolower(value) to make it return lowercase.

I find this link helpful: http://laravel-guide.readthedocs.io/en/latest/eloquent-mutators/#defining-a-mutator 

Leave a Reply

Your email address will not be published. Required fields are marked *