Introduction
This technique is really useful to check if an Eloquent relation is loaded on a Model, in order to efficiently generate an appended property.
For example, this approach is particularly useful in a multilingual application, where you can have an entity that has a number of related translations in different languages. Consider the following code:
<?php
class Entity extends Model
{
public function translations()
{
return $this->hasMany('Translation'); …