SOFTonSOFA

Tag: ORM

Laravel 5 Eloquent Global Scope how-to

scope

If you are looking for an example of Eloquent Global Scope feature, then you’re in the right place!

Check the ready-to-use demo at …

Continue reading

Tweaking Eloquent relations – how to get N related models per parent ?

related

Previously I showed you how to get single related model per each parent, while eager loading the hasMany relation. That was pretty easy and we just made the most of the Eloquent.

However, most likely the time will come, when you need several related models per parent.

It won’t be as easy, but it’s far from impossible, so let’s do it!

Continue reading

Tweaking Eloquent relations – how to get latest related model?

lates

Have you ever needed to show only single related model from the hasMany relationship on a set of parents?

Being it latest, highest or just random, it’s not very clever to load whole collection using eager loading, just like running query per every parent.

Of course you can do that better, and now let me show you how.  Continue reading

Querying relations with Eloquent in Laravel 4

eloquent

Laravel ORM Eloquent is brilliant!

That being said, let’s try to tackle very common questions that appear when you try to get related models loaded.

Continue reading

Copyright © 2017 SOFTonSOFA

Theme by Anders NorenUp ↑