SOFTonSOFA

Tag: laravel (page 2 of 2)

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

How to store clients in database? That is, Party Model implemented in Laravel 4 – part 1

party-model

Have you ever been building any app that handled client’s data, was it e-commerce, crm or anything similar, you surely wondered, how to store it in the database.

Most of the time we consider client as Organization or Person, one or the other. Obviously the two are completely different entities in real life, so it wouldn’t be wise to treat them the same. However, speaking of business, we want to treat both entities like a client, no matter if it’s a company or an individual.

So the problem arises, how to design the database efficiently while not having to do checks here and there within our code, to pick what entity we are dealing with this time.

And here comes the Party Model  Continue reading

Querying relations in Laravel 4: nested relation

eloquent-2

Previously we dealt with simple relations defined in Eloquent models and eager loading them in order to save database queries.

Now imagine nested relations like this:

So there are one-to-many relations between posts & categories as well as comments & posts.

Above relations look like this:

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

New project open – RMA@SOFA

Starting new project called RMA@SOFA.

It will cover most of the needs of service points, starting with IT services, then much more!

Roadmap and features outline will be here soon. Also there will be case study for package development and a few tutorial-ish posts/screencasts.

Stay tuned!

Newerposts

Copyright © 2017 SOFTonSOFA

Theme by Anders NorenUp ↑